Jump to content

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.

Thanks

$labels = array( "first_name"=>"First Name:",
"last_name"=>"Last Name:",
"email"=>"Email Address:",
"address1"=>"Street Address Line 1:",
"address2"=>"Street Address Line 2:",
"city"=>"City:",
"state"=>"State:",
"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'
cellpadding='2'>\n";
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>
</tr>";
}
echo "</table>
<div align='center'><input type='submit' value='Submit Information'> </div>
</form>";
Link to comment
https://forums.phpfreaks.com/topic/19800-trouble-saving-email-address-in-a-form/
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
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.
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.