SunQuest
           Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old October 11th, 2002, 01:13 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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>";
}
?>

Reply With Quote
  #2  
Old October 11th, 2002, 11:29 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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);

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > phpMyAdmin 2.2.2


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway