Jump to content


This topic is now archived and is closed to further replies.


Trouble saving email address in a form

Recommended Posts

I am very new to PHP (self learning) and I am having a problem with a form I am setting up to collect customers information to opt in for a newletter. I can record all data to my database except an email address. I have not put any restrictions on my data types yet since i was just testing this out. I can save "words" to the "email" column of my database but if i do a formal email address with both the (at) and the (dot com) it gives me a "403 forbidden error" "Server configuration does not allow access to this page."

I contacted my web hosting company and asked them if there was an error on their end and they said it had to be in my code (attached below). Please let me know if there is any reason why I could save (cbauer22@gmail.c but i can not save cbauer22@gmail.com) to a mysql database.


$labels = array( "first_name"=>"First Name:",
"last_name"=>"Last Name:",
"email"=>"Email Address:",
"address1"=>"Street Address Line 1:",
"address2"=>"Street Address Line 2:",
"zip"=>"Zip Code:",
"phone"=>"Phone Number:");

echo "<p align='center'>
<b>Please enter your information below.</b><hr>";
echo "<form action='saveaddress.php' method='POST'>
<table width='95%' border='0' cellspacing='0'
foreach($labels as $field=>$label)
echo "<tr>
<td align='right'> <B>{$labels[$field]} </br></td>
<td><input type='text' name='$field' size='65'
maxlength='65' ></td>
echo "</table>
<div align='center'><input type='submit' value='Submit Information'> </div>

Share this post

Link to post
Share on other sites
Can you show us the code where you're actually using the INSERT statement?

Share this post

Link to post
Share on other sites
Like i said i'm new at this, so i hope this is the code you were refering to......

$connection = mysql_connect($host,$user,$password)
      or die ("couldn't connect to server");
    $db = mysql_select_db($database,$connection)
      or die ("Couldn't select database");

    $query = "INSERT INTO customer (first_name,last_name,email,address1,address2,city,state,zip,phone)
                    VALUES ('$first_name','$last_name','$email','$address1','$address2','$city','$state','$zip','$phone')";
    $result = mysql_query($query)
      or die ("Couldn't execute query.");
    echo "Thank You

Share this post

Link to post
Share on other sites
And I assume that is in a file called "saveaddress.php"?  That code looks fine except for the fact that all your variables in the VALUES part should be '$_REQUEST['first_name']'... etc.  You can't access the variables directly like that on another page.

Share this post

Link to post
Share on other sites


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.