Jump to content

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

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.