Page 1 of 1

My form won't upload to MySQL table!

Posted: Mon Sep 01, 2008 1:05 pm
by cap2cap10
:banghead: I can't seem to get this form to upload hidden information to DB table
Here is the code:

Code: Select all

<table align=left width=700> <tr>
<td align=left valign=top ><form method="POST" action="insert.php">
<input type=hidden name=username value=$_POST['username']>
<input type=hidden name=password value=$_POST['password']>
<input type=hidden name=FName value=$_POST['FName']>
<input type=hidden name=MName value=$_POST['MName']>
<input type=hidden name=LName value=$_POST['LName']>
<input type=hidden name=Email value=$_POST['Email']>
<input type=hidden name=Address value=$_POST['Address']>
<input type=hidden name=Suite value=$_POST['Suite']>
<input type=hidden name=City value=$_POST['City']>
<input type=hidden name=State value=$_POST['State']>
<input type=hidden name=Zipcode value=$_POST['Zipcode']>
<input type=hidden name=Country value=$_POST['Country']>
<input type=hidden name=Hphone_1 value=$_POST['Hphone_1']>
<input type=hidden name=Hphone_2 value=$_POST['Hphone_2']>
<input type=hidden name=Hphone_3 value=$_POST['Hphone_3']>
<input type=hidden name=Mphone_1 value=$_POST['Mphone_1']>
<input type=hidden name=Mphone_2 value=$_POST['Mphone_2']>
<input type=hidden name=Mphone_3 value=$_POST['Mphone_3']>
<input type=hidden name=Wphone_1 value=$_POST['Wphone_1']>
<input type=hidden name=Wphone_2 value=$_POST['Wphone_2']>
<input type=hidden name=Wphone_3 value=$_POST['Wphone_3']>
<input type=hidden name=Extension value=$_POST['Extension']>
<input type="hidden" name="submitted" value="true" />
<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">
<input type="button" name="submit" value="Yes, my information is correct!"></form></td>
</tr>
</table><P>
Here is the dbase insert code:

Code: Select all

<?php
ob_start();
 
// Connect to server and select databse.
mysql_connect('*****************', 'js_info', '************') or die(mysql_error());
mysql_select_db('js_info') or die(mysql_error());
 
mysql_query("INSERT INTO js_login(username, password, FName, MName, LName, Email) VALUES ('$username', '$password',
 '$FName', '$MName', '$LName', '$Email') ") or die(mysql_error());
 
mysql_query("INSERT INTO js_account(FName, MName, LName, Email, Address, Suite, City, State, Zipcode,
Country, Hphone_1, Hphone_2, Hphone_3, Mphone_1, Mphone_2, Mphone_3, Wphone_1, Wphone_2, Wphone_3, Extension)
VALUES ('$FName', '$MName', '$LName', '$Email','$Address', '$Suite', '$City', '$State', '$Zipcode',
'$Country', '$Hphone_1', '$Hphone_2', '$Hphone_3', '$Mphone_1', '$Mphone_2', '$Mphone_3', '$Wphone_1',
'$Wphone_2', '$Wphone_3', '$Extension') ") or die(mysql_error());
 
include 'welcome.php';
mysql_close();
 
header("Location: login1.php");
ob_end_flush();
?>
Please enlighten this novice as to what I am missing or doing wrong

Batoe

Re: My form won't upload to MySQL table!

Posted: Mon Sep 01, 2008 1:22 pm
by dude81
convert each tag of this kind

Code: Select all

 
 
 <input type=hidden name=username value=$_POST['username']>
 
 
convert all of them to

Code: Select all

<input type="hidden" name="username" value="<?php echo $_POST['username']; ?>" />
.
And this to

Code: Select all

<input type="submit" name="submit" value="Yes, my information is correct!">
Also a security note, exposing your server details like this

Code: Select all

 
 mysql_connect('p41mysql37.secureserver.net', 'js_info', 'Salt943Tear980') or die(mysql_error());
 mysql_select_db('js_info') or die(mysql_error());
 
is dangerous