Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3463 | Replies: 3
heres the code to send the info
and here is the code to show the information entered by the user
[php]<?
$DBhost = "localhost";
$DBuser = "michael";
$DBpass = "koolaide";
$DBName = "phpforms";
$table = "information";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$id','$name','$email','$opinion')";
$results = mysql_query($sqlquery);
mysql_close();
echo "
<html>
<head>
<title> PHP and MySQL </title>
</head>
<body>
<center>
<table border='0' width='500'>
<tr>";
echo " <td>
<font face='verdana' size='+0'>
<center>
<p>You Just Entered This Information Into the Database</p>
</center>";
echo " <blockquote>
<center>
<p>
Name :<p> $name E-Mail :</p> $email <p>Opinion :</p> $opinion
</p>
</center>
</blockquote>
</td>
</tr>
</table>
</center>
</body>
</html>";
?>
[/php]
heres the problem, when i run the HTML on the first page and fill out the form, i press send the info, it should bring up another page saying You entered so and so information. but instead i get you entered so and so info but it doesnt list the info, adding to that, im very noob to PHP, this is another tutorial that i found, and im begining to think that alot of tutorials have errors in them or somthing. i even went into my mysql and added the database and lines of info needed (again using his tutorial on how to) any help would be greatly appreciated.
ok, so i was able to fix the form, and ill post how i did it too.
[php]$name = "$_POST[name]";
$email = "$_POST[email]";
$opinion = "$_POST[opinion]";[/php]
needed to be defined at the top of the page. now when i view my databases via phpmyadmin, i can see that the information has been added to the database, but now i need to write a script that will print out all data in the database to onscreen.
<html> <HEAD> <title> form Handling with PHP </title> </head> <body bgcolor="#FFFFFF"> <center> <form method=post action="submittedinfo.php"> <input type="hidden" name="id" value="NULL"> <table> <tr> <td colspan="2"><font SIZE="+0" face="verdana"> Lets see if we cant get this form to work! </td> </tr> <tr> <td> </td> </tr> <tr> <td align="left"><font SIZE="+0" face="verdana"> <b>Your name <br \>Your E-Mail Address</b> </td> <td> <input type="text" name="name" id="name"> <br /> <input type="text" name="email" id="email"> </td> </tr> <tr> <td colspan="2"><center> <SELECT name="opinion" id="opinion"> <option value="is great">I like your site</option> <option value="is OK">Your Site is OK</option> <option value="is horrible">Your Site is horrible</option> </SELECT><p><input type="submit" value="Tell us!"> </td> </tr> </table> </form> </body> </html>
and here is the code to show the information entered by the user
[php]<?
$DBhost = "localhost";
$DBuser = "michael";
$DBpass = "koolaide";
$DBName = "phpforms";
$table = "information";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$id','$name','$email','$opinion')";
$results = mysql_query($sqlquery);
mysql_close();
echo "
<html>
<head>
<title> PHP and MySQL </title>
</head>
<body>
<center>
<table border='0' width='500'>
<tr>";
echo " <td>
<font face='verdana' size='+0'>
<center>
<p>You Just Entered This Information Into the Database</p>
</center>";
echo " <blockquote>
<center>
<p>
Name :<p> $name E-Mail :</p> $email <p>Opinion :</p> $opinion
</p>
</center>
</blockquote>
</td>
</tr>
</table>
</center>
</body>
</html>";
?>
[/php]
heres the problem, when i run the HTML on the first page and fill out the form, i press send the info, it should bring up another page saying You entered so and so information. but instead i get you entered so and so info but it doesnt list the info, adding to that, im very noob to PHP, this is another tutorial that i found, and im begining to think that alot of tutorials have errors in them or somthing. i even went into my mysql and added the database and lines of info needed (again using his tutorial on how to) any help would be greatly appreciated.
ok, so i was able to fix the form, and ill post how i did it too.

[php]$name = "$_POST[name]";
$email = "$_POST[email]";
$opinion = "$_POST[opinion]";[/php]
needed to be defined at the top of the page. now when i view my databases via phpmyadmin, i can see that the information has been added to the database, but now i need to write a script that will print out all data in the database to onscreen.
Last edited by samaru : Jun 15th, 2004 at 2:00 am.
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode