Jump to content


Photo

Trouble saving email address in a form


  • Please log in to reply
3 replies to this topic

#1 cab

cab
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 September 2006 - 07:20 PM

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>";

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 September 2006 - 07:25 PM

Can you show us the code where you're actually using the INSERT statement?

Info: PHP Manual


#3 cab

cab
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 September 2006 - 07:28 PM

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

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 September 2006 - 07:32 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users