|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
phpMyAdmin 2.2.2
Hi, my name is Rasun Williams and I am having trouble entering the data from a html form using php into a mysql database. I am using phpMyAdmin 2.2.2 and I created a table called innovations with the variables id, first, last, email, address, city, state, zipcode, subject, message and date. When I submit the form I get a message that states process complete, however the data is not entering the mysql database. Can somebody point me into the right direction. Thank you for your time and patience!
-------------> Here is the code for the html form and the php code. -------------------------------------------------------------------------------- <?php /* constant declarations */ // Left out the user, password, and database name define('MYSQL_HOST', 'localhost'); define('MYSQL_USER', ''); define('MYSQL_PASS', ''); define('MYSQL_DB', ''); /* Main Program */ if(! isset($action) ) { $action = NULL; } switch ($action) { default: displayform(); break; case 'signup': signUp($HTTP_POST_VARS); displaysuccess(); break; } /*definitions are below this point */ function displayform() { head(); ?> <form action = "<?php echo $PHP_SELF ?>" method = "post"> <input type = "hidden" name = "action" value = "signup"> <b>First Name: </b><input type = "text" name = "first">* required<br> <p> <b>Last Name: </b><input type = "text" name = "last">* required<br> <p> <b>E-mail: </b><input type = "text" name = "email">* required<br> <p> <b>Address: </b><input type = "text" name = "address">(optional)<br> <p> <b>City: </b> <input type = "text" name = "city">(optional)<br> <p> <p> <b>State:</b> <input type = "text" name = "state">(optional)<br> <p> <b>Zip Code:</b><input type = "text" name = "zipcode">(optional)<br> <p> <b> Subject: </b> <select name = "subject"> <option selected> Comment </option> <option>Complaint</option> <option>Suggestion</option> </select> <br> <br> <b> Message: </b> <p> <textarea name = "message" rows = "5" cols = "40"> </text> <br> <br> <input type = "submit"> </form> <?php foot(); } function signUp($input) { // If we fail to conect, we can't keep going, so we exit if(! mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) ) { echo ' Failed to connect to host " ' . MYSQL_HOST . ' ".'; exit; } mysql_select_db(MYSQL_DB); mysql_query("INSERT INTO --------- SET first = '{$input ['first']}', last = '{$input ['last']}', email = '{$input ['email']}', address = '{$input ['address']}', city = '{$input ['city']}', state = '{$input ['state']}', zipcode = '{$input ['zipcode']}', subject = '{$input ['subject']}', message = {$input ['message']} "); } function displaysuccess() { head(); ?> Your submission has been completed! <?php foot(); } function head() { echo "<html> <body>"; } function foot() { echo "</html> </body>"; } ?> |
|
#2
|
|||
|
|||
|
RE: phpMyAdmin 2.2.2
Take your query and place it into a variable so you can then echo it out. Then, look at the query, make sure it looks good and run it manually in phpmyadmin:
$query = "INSERT INTO --------- SET first = '{$input ['first']}', last = '{$input ['last']}', email = '{$input ['email']}', address = '{$input ['address']}', city = '{$input ['city']}', state = '{$input ['state']}', zipcode = '{$input ['zipcode']}', subject = '{$input ['subject']}', message = {$input ['message']} "; echo $query; mysql_query($query); |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > phpMyAdmin 2.2.2 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|