SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Not inserting

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not inserting

    Hello,

    I have created a database, and once the form is submitted, it's not inserting into the database. Can anyone see an error in this code?

    dowork.php
    PHP Code:
    <?php
    $submit 
    $_POST['submit'];
    $firstname $_POST['firstname'];
    $lastname $_POST['lastname'];
    $birthdate $_POST['birthdate'];
    $email $_POST['email'];
    $phone $_POST['phone'];

    if (!
    $submit) {
    $message"<center><b>Register now and save $2 at the door!<i><br />
     * = required field</;></i></center>"
    ;
    }

    if (
    $submit && (!$firstname || !$lastname || !$birthdate)){
    $error"<center><b>You didn't fill in all Required fields. Please try again!</b></center>";
    }

    if ((
    $submit && $firstname && $lastname && $email) &&
    (!
    preg_match("/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9-.]+$)+/"$email))){
    $error"<center><b>Invalid E-Mail Address. Please Try Again!</b></center>";
    }

    if ((
    $submit && $firstname && $lastname && $email && $phone) &&
    (!
    preg_match("/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9-.]+$)+/"$email))){

    $con mysql_connect("localhost","root","");

    if (!
    $con)
    {
    die(
    'Could not connect: ' mysql_error());
    }
    mysql_select_db("crash"$con);
    $sql "INSERT INTO attendees (firstname,lastname,birthdate,email,phone)
    VALUES ('
    $firstname','$lastname','$birthdate','$email','$phone')";

    if (!
    mysql_query($sql$con))
    {
    die(
    'Error: ' mysql_error());
    }
    $message"<center><b>Thank you.  You are now registered</b></center>";
    mysql_close($con);
    }

    header ("Location: yay.php");

    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Are you developing locally?
    Knowledge is for the World. Get it. Love it. Share it.
    www.whatsthelatest.net

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I am.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please check your database name, table names, field names, make sure they are exact.
    Knowledge is for the World. Get it. Love it. Share it.
    www.whatsthelatest.net

  5. #5
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,998
    Mentioned
    100 Post(s)
    Tagged
    0 Thread(s)
    What error if any is MySQL giving?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •