Jump to content

issues $_POST email to database


Guber-X

Recommended Posts

im just making a simple contact form to submit to my database. it always comes up with this error.

 

Error, insert query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@hotmail.com, 'Test Msg')' at line 1

 

my form involves these input boxes in the same order and also what I entered into those boxes

 

Name: Shane

Phone: 2502501234

Email: mymail@hotmail.com

Msg: Test Msg

 

for my understanding its not taking the "Email" input box correctly or something. heres my code...

 

<?php
if (isset($_POST['submit'])) {
        	
$name    = $_POST['name'];
$phone 	 = $_POST['phone'];
$email	 = $_POST['email'];
$msg	 = $_POST['msg'];
        	
$querys  = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', $phone, $email, '$msg')";
       	mysql_query($querys) or die("Error, insert query failed: " . mysql_error());

echo '<br /><br />Thank You!';
} else {
        echo '<form method="post">',
                '<table>',
                '<tr>',
                '<td>Name: </td>',
                '<td>',
                '<input type="text" name="name" id="name">',
                '</td>',
                '</tr>',
                '<tr>',
                '<td>Phone #:</td>',
                '<td>',
                '<input type="tel" name="phone" id="phone">',
                '</td>',
                '</tr>',
                '<tr>',
                '<td>Email:</td>',
                '<td>',
                '<input type="email" name="email" id="email">',
                '</td>',
                '</tr>',
                '<tr>',
                '<td class="msg">Message:</td>',
                '<td>',
                '<textarea id="msg" name="msg" rows="10" cols="40"></textarea>',
                '</td>',
                '</tr>',
                '<tr>',
                '<td rowspan="2">',
                '<input type="submit" value="Submit" id="submit" name="submit">',
                '</td>',
                '</tr>',
                '</table>',
                '</form>';
}
?>

 

Link to comment
Share on other sites

holy hell im blind... i found my error...

 

$querys  = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', $phone, $email, '$msg')";

 

i was missing some quotations by the $phone and $email... lol. should be like this

 

$querys  = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', '$phone', '$email', '$msg')";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.