Jump to content

PHP Form help


gfmaking

Recommended Posts

what is wrong with this code? can any one help please. I have tried evrything


<?
$username="gfm";
$password="chris";
$database="Order_db";
$host="localhost";

$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zip'];
$Country=$_POST['Country'];
$Phone=$_POST['Phone'];
$E-Mail=$_POST['E-Mail'];
$Product_01=$_POST['Product01'];
$Product_02=$_POST['Product02'];

$connection = mysql_connect($host,$username,$password)or die( "Unable to connect to server");
$db= mysql_select_db($database,$connection) or die( "Unable to select database");

$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address, City, State, Zip, Country, phone, E-mail, Product01, Product02) VALUES
('$First_Name','$Last_Name','$Address','$City','$State','$Zip','$Country','$phone','$E-mail','$Product01','$Product02')";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with
query ". $query); // see the problem

if($result) {
echo "Thank You For your Order";
}

mysql_close();
?>
Link to comment
https://forums.phpfreaks.com/topic/12724-php-form-help/
Share on other sites

What's wrong with it? What does it do? What doesn't it do that you expect? What error messages does it generate? I'm skeptical about the username and database name you use in your code. Normally, the username and database name have your web account username as part of them. Don't post your real database access details (you never know who's reading these posts), but do check that what you are using makes sense.
Link to comment
https://forums.phpfreaks.com/topic/12724-php-form-help/#findComment-48768
Share on other sites

[!--quoteo(post=387148:date=Jun 23 2006, 09:19 AM:name=RonScott)--][div class=\'quotetop\']QUOTE(RonScott @ Jun 23 2006, 09:19 AM) [snapback]387148[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I am a newbie also, but I think one problem is using e-mail.

PHP wants to see this as e minus mail - mathmatical operation.

Make it email. [/quote]

Great catch, Ron. MySQL would choke on e minus mail (and error trapping in the OP's script should show that).
Link to comment
https://forums.phpfreaks.com/topic/12724-php-form-help/#findComment-48793
Share on other sites

Hi Andy,

I used HTML Form to submit contact and order info to my mysql database. When Submiting the form balnk page apears & nothing was been inserted in to the database. Of course I used "post" method for my HTML form and I saved the above code in to action.php file.

Please look in to it.
Link to comment
https://forums.phpfreaks.com/topic/12724-php-form-help/#findComment-48867
Share on other sites

Archived

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

×
×
  • 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.