Jump to content


Photo

PHP Form set tp


  • Please log in to reply
3 replies to this topic

#1 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 June 2006 - 09:25 PM

I want people to fill out my form, which is contact information, and I want the info directly load in to mysql database. Please look the PHP code. On the HTML form I inserted <form method="post" form action="action.php"> what is wrong? my database is running on my webhosting server in one of the sub folders. please please some one help me.

<?
$username="myuser";
$password="mypass";
$database="Order_db";

$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip_Code=$_POST['Zip'];
$Country=$_POST['Country'];
$phone=$_POST['phone'];
$E-Mail=$_POST['E-mail'];
$Product_01=$_POST['Product01'];
$Username8=$_POST['Product02'];

mysql_connect('genesis.com/fpdb/php/index.php',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO contacts VALUES ('','$First_Name','$Last_Name','$Address','$City','$State','$Zip','$Country','$phone','$E-mail','$email','$Product01','$Product02')";
mysql_query($query);

mysql_close();
?>



#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 21 June 2006 - 09:54 PM

Mysqlconnect typically gets the value "localhost" -- not a php file location. you might check to make sure you're connecting to the right place.

Also, if your action is to action.php, I would assume the code you showed in your post is actually named "action.php"

#3 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 June 2006 - 10:01 PM

[!--quoteo(post=386600:date=Jun 21 2006, 05:54 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 21 2006, 05:54 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Mysqlconnect typically gets the value "localhost" -- not a php file location. you might check to make sure you're connecting to the right place.

Also, if your action is to action.php, I would assume the code you showed in your post is actually named "action.php"
[/quote]




Thanx for your response,

I put my action.php on my rootweb and edit to "localhost" but when submiting the form the browser point to action.php and show blank page.

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 21 June 2006 - 10:14 PM

it is very likely that you posted data to the mysql database. check your database and see if the new stuff has been added.

If not, you might consider adding a
echo mysql_error();
line after the mysql_query to make sure you didn't get an error.

you might also consider adding something to this page... "thanks for filling out the form" etc, so the users don't get a blank page.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users