|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm totally lost!
I know this can't be rocket science, but I'm lost. I created a MySQL database table in Godaddy, and a form in my HTML. But I can't figure out how to make the PHP file work! At least I'm not getting an error, but no records are going into the database.
Here is my form in my website: <form action="email.php" method="post" enctype="multipart/form-data"> <table cellpadding="0" cellspacing="0" border="0" bgcolor="#999999"><tr><td> <table cellpadding="10" cellspacing="1"><tr bgcolor="#F2F4FA"> <td bgcolor="#FFFFFF"> <font face="Verdana,Arial,Helvetica"><b>Your first name:</b></font><br /> <input type="text" name="first name" size="20" /><br /> <font face="Verdana,Arial,Helvetica"><b><br> Your email</b></font><br /> <input type="text" name="email" size="20"><br /> <br /><div align="center"> <input type="submit" name="submit" value=" Send "> <input type="reset" name="reset" value=" Clear "> </div></td></tr></table></td></tr></table> </form></div> Here is the sample code for the PHP (without my specific info), and I really think this should be SIMPLE!!!! (of course, I put in the right values, but it still didn't make it into the database--no error--but no record) <?php //Sample Database Connection Syntax for PHP and MySQL. //Connect To Database $hostname="mysql.secureserver.net"; $username="MYUSERNAME"; $password="MYPASSWORD"; $dbname="NAMEOFGODADDYDATABASE"; $usertable="NAMEOFTABLE"; $yourfield = "NUMBEROFFIELDS"; mysql_connect($hostname,$username, $password) OR DIE ("<html><script language='JavaScript'<alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>"); mysql_select_db($dbname); # Check If Record Exists $query = "SELECT * FROM $usertable"; $result = mysql_query($query); if($result) { while($row = mysql_fetch_array($result)) { $name = $row["$yourfield"]; echo "Name: ".$name."<br>"; } } ?> PLEASE help. Thanks, Susan (susan@perimenopausesupport.com) |
|
#2
|
||||
|
||||
|
First, use a more descriptive title for your posts. Many people simply ignore posts with titles like "HELP" or "N00b question" or "I'm lost". Just a tip. You also might want to post future php questions in the PHP forum.
Ok, now as to your problem. PHP is not really my language, but from looking at your code, you don't have anything that inserts data into your database. As I see it, your current php checks username and password against a database (where the username and password are coming from, I don't know). But to insert data into the database, you'll need another query, along the lines of Code:
INSERT INTO tablename VALUES value1, value2... Try making an INSERT statement with the data (probably form field names?) that you want to insert. If it still doesn't work, post a question in the PHP forum (with a descriptive title!), and some of our resident PHP gurus will help you out. I know at least one guy specializes in PHP and mySQL, so they can help you fine tune your code. Good Luck! Dave
__________________
--Dave-- U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM= Last edited by karsh44 : August 15th, 2003 at 08:40 AM. |
|
#3
|
|||
|
|||
|
Oh, I thought this WAS the PHP forum. Ahhh well. I will look at the code you sent, and appreciate your suggestions. Susasn
|
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > I'm totally lost! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|