Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:08:11+00:00 2026-05-20T11:08:11+00:00

Trying to do client and server side validation I have 2 files. The client

  • 0

Trying to do client and server side validation I have 2 files. The client side is fine, it seems theres an error with the server side, it doesnt send at all.

Thanks.

form.php:

<html>
<head>
<style type="text/css">
label.error{color:red; font-weight:bold;}
</style>
<script type="text/javascript" src="jquery.js"> </script>
<script type="text/javascript" src="validation.js"> </script>
<script type="text/javascript"> 
$.validator.setDefaults({
    submitHandler: function() { alert("submitted!"); }
});

$().ready(function() {
    // validate the comment form when it is submitted
    $("#commentForm").validate();

    // validate signup form on keyup and submit
    $("#signupForm").validate({
        rules: {
            firstname: "required",
            lastname: "required",
            username: {
                required: true,
                minlength: 2
            },
            password: {
                required: true,
                minlength: 5
            },
            confirm_password: {
                required: true,
                minlength: 5,
                equalTo: "#password"
            },
            email: {
                required: true,
                email: true
            },
            topic: {
                required: "#newsletter:checked",
                minlength: 2
            },
            agree: "required"
        },
        messages: {
            firstname: "Please enter your firstname",
            lastname: "Please enter your lastname",
            username: {
                required: "Please enter a username",
                minlength: "Your username must consist of at least 2 characters"
            },
            password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long"
            },
            confirm_password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long",
                equalTo: "Please enter the same password as above"
            },
            email: "Please enter a valid email address",
            agree: "Please accept our policy"
        }
    });

    // propose username by combining first- and lastname
    $("#username").focus(function() {
        var firstname = $("#firstname").val();
        var lastname = $("#lastname").val();
        if(firstname && lastname && !this.value) {
            this.value = firstname + "." + lastname;
        }
    });

    //code to hide topic selection, disable for demo
    var newsletter = $("#newsletter");
    // newsletter topics are optional, hide at first
    var inital = newsletter.is(":checked");
    var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
    var topicInputs = topics.find("input").attr("disabled", !inital);
    // show when newsletter is checked
    newsletter.click(function() {
        topics[this.checked ? "removeClass" : "addClass"]("gray");
        topicInputs.attr("disabled", !this.checked);
    });
});
</script> 

</head>

<body>
<form class="cmxform" id="commentForm" method="post" action="f_validate.php" > 
    <fieldset> 
        <legend>Please provide your name provide required fields below.</legend> 
        <p> 
            <label for="cname">* Name</label> 
            <input id="cname" name="name" class="required" minlength="2" /> 
        <p> 
            <label for="cemail">* Email</label> 
            <input id="cemail" name="email" class="required email" /> 
        </p> 
        <p> 
            <label for="curl">URL</label> 
            <input id="curl" name="url" class="url" value="" /> 
        </p> 
        <p> 
            <label for="ccomment">* Comment</label> 
            <textarea id="ccomment" name="comment" class="required"></textarea> 
        </p> 
        <p> 
            <input class="submit" type="submit" value="Submit"/> 
        </p> 
    </fieldset> 
</form> 

</body>

</html>

f_validate.php

<?php 
$errors = '';
$myemail = 'myemail@email.com';
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['comment']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$comment = $_POST['comment']; 

if (!eregi(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
    $to = $myemail; 
    $email_subject = "Contact form submission: $name";
    $email_body = "You have received a new message. ".
    " Here are the details:\n Name: $name \n Email: $email_address \n Message \n $comment"; 

    $headers = "From: $myemail"; 
    $headers .= "Reply-To: $email_address";

    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: http://www.josephdickinson.com');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
    <title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:08:12+00:00Added an answer on May 20, 2026 at 11:08 am
    1. Check if the eregi regex actually works (eregi is deprecated, by the way, you should switch to preg_match instead
    2. Check the return value from the mail() function – if there was a problem handing off the email to the local SMTP server, mail will return boolean FALSE.
    3. CHeck the SMTP server’s log – the mail could’ve gotten stuck in a queue, been rejected by the receiving server, dumped into a spam folder, etc… Just because mail() returns true doesn’t mean the email was actually delivered to the recipient.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do client side custom validation. I have the following code
I have created small socket programs (client/server). Client will transfer all formats of files
I'm trying to use __doPostBack to pass some data from client to server side.
I have form where a particular field requires both server side and client side
I'm trying to log client's exceptions on the server side. So I need to
I am trying to both create the Server and client side of a jsonp
I'm trying to adress the following issue: I have a server side .net application
I'm trying to get client-side validation running. I've put together a very simple test
Im trying to send an object from client to server and one of the
I'm trying to send XML doc to server from client. But when server get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.