Print Reseller Scheme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Form validation, this should be simple so I'm told?

Discussion in 'Website Coding & Programming Forum:' started by Bleek, Sep 9, 2012.

  1. Bleek

    Bleek Junior Member

    Another request for some php help on what is probably the most simple php form ever... :wacko:

    I copied a tutorial off the next and here's the content:


    $EmailFrom = "";
    $EmailTo = "";
    $Subject = "";
    $Name = Trim(stripslashes($_POST['Name']));
    $Tel = ($_POST['Tel']);
    $Message = Trim(stripslashes($_POST['Message']));

    // validation
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

    After that I tried to add validation so each field was required, I used other web tutorials but I'm failing miserably to get it to work.

    It's probably simple but I really don't know php at all, can anyone shed any light?
    Twisted Tree Media likes this.
  2. Levi

    Levi Moderator Staff Member

    well I would point you in the direction of a post by jazajay but I can't seem to find it with the new updated forum layout... we're a bit limited on the user threads fronts, there's only 4/5 per user by the looks of it :(
  3. Bleek

    Bleek Junior Member

    I'll search his username and see what I come up with!
  4. Squiddy

    Squiddy Guest

    What errors do you get? Is this hosted online anywhere for us to look at? Can you post the link to the tutorial as well please.
  5. Jazajay

    Jazajay Active Member

    You can follow the one in my sig....I think it should still work.
    Alternatively, just change the form to this:

    Please note:
    This form is pretty basic - and I wrote that off the cuff. Any errors let us know and I'm sure one of us will correct it/them. Looks okay, but needs testing.
    Hope it helps
    berry likes this.

Share This Page