Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

PHP/MySQL question

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

QBert

Established Member
Impact
10
Can someone tell me why this dosent work.

after submitting it just restes without entering any data
Code:
<html>
<body>

<?php

if ($submit) {
  // process form
  $db = mysql_connect("localhost", "bertie_username", "password");
  mysql_select_db("bertie_assesment",$db);
  $sql = "INSERT INTO profiles (username,password,email,firstname,lastname,city,state,countrey,zip,birthday,gender,squestion,sawnser) VALUES ('$username','$password','$email','$firstname','$lastname','$city','$state','$countrey','$zip','$birthday','$gender','$squestion','$sawnser')";
  $result = mysql_query($sql);
echo  "<?php echo $PHP_SELF?>";

}

  ?>


<form method="post" action="<?php echo $PHP_SELF?>">
<table border=0>
<TR>
<TD>Username:</TD><TD><input type="Text" name="username"></TD>
</TR>
<TR>
<TD>Password:</TD><TD><input type="Text" name="password"></TD>
</TR>
<TR>
<TD>Valid Email Address:</TD><TD><input type="Text" name="email"></TD>
</TR>
<TR>
<TD>Given Names:</TD><TD><input type="Text" name="firstname"></TD>
</TR>
<TR>
<TD>Family Name:</TD><TD><input type="Text" name="lastname"></TD>
</TR>
<TR>
<TD>City:</TD><TD><input type="Text" name="city"></TD>
</TR>
<TR>
<TD>State:</TD><TD><input type="Text" name="state"></TD>
</TR>
<TR>
<TD>Country:</TD><TD><input type="Text" name="countrey"></TD>
</TR>
<TR>
<TD>Zip Code:</TD><TD><input type="Text" name="zip"></TD>
</TR>
<TR>
<TD>Birth Date</TD><TD><input type="Text" name="birthday"></TD>
</TR>
<TR>
<TD>Gender:</TD><TD><input type="Text" name="gender"></TD>
</TR>
<TR>
<TD>Secret Question:</TD><TD><input type="Text" name="squestion"></TD>
</TR>
<TR>
<TD>Secret Answer:</TD><TD><input type="Text" name="sawnser"></TD>
</TR>
<TR>
<TD colspan="2"><center><input type="Submit" name="submit" value="Enter information"></center></TD>
</TR>
</form>

  <?php
 // end if

?>

</body>
</html>

However this one works, the only thing ive changed is added more feilds in the form and trying to do it to a different database.

Code:
<html>
<body>

<?php

if ($submit) {
  // process form
  $db = mysql_connect("localhost", "bertie_username", "password");
  mysql_select_db("bertie_mobster",$db);
  $sql = "INSERT INTO employees (msg) VALUES ('$msg')";
  $result = mysql_query($sql);
echo  "<?php echo $PHP_SELF?>";

}

  ?>


<form method="post" action="<?php echo $PHP_SELF?>">
<table border=0>
<TR>
<TD>Email:</TD><TD><input type="Text" name="msg"></TD>
</TR>
<TR>
<TD colspan="2"><center><input type="Submit" name="submit" value="Enter information"></center></TD>
</TR>
</form>

  <?php
 // end if

?>

</body>
</html>

Thanks heaps

50np$'s to whoever helps :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I don't know why it doesn't work, but try the following code and see what happens (I've added some debugging messages to your code, so it might help show whats going wrong).

Hope that helps,

Sam

Code:
<html>
<body>

<?php

// turn on all error reporting...
error_reporting(E_ALL);

if (isset($_POST['submit'])) {
  // process form

 echo "Processing submission...";

  $db = mysql_connect("localhost", "bertie_username", "password") or die("Could not connect to database: ".mysql_error());
  mysql_select_db("bertie_assesment",$db) or die("Could not select database: ".mysql_error());
  $sql = "INSERT INTO profiles (username,password,email,firstname,lastname,city,state,countrey,zip,birthday,gender,squestion,sawnser) VALUES ('$username','$password','$email','$firstname','$lastname','$city','$state','$countrey','$zip','$birthday','$gender','$squestion','$sawnser')";
  $result = mysql_query($sql) or die("Error with insert: ".mysql_error()." <br />SQL: $sql");
echo  "<?php echo $PHP_SELF?>";

}

  ?>


<form method="post" action="<?php echo $PHP_SELF?>">
<table border=0>
<TR>
<TD>Username:</TD><TD><input type="Text" name="username"></TD>
</TR>
<TR>
<TD>Password:</TD><TD><input type="Text" name="password"></TD>
</TR>
<TR>
<TD>Valid Email Address:</TD><TD><input type="Text" name="email"></TD>
</TR>
<TR>
<TD>Given Names:</TD><TD><input type="Text" name="firstname"></TD>
</TR>
<TR>
<TD>Family Name:</TD><TD><input type="Text" name="lastname"></TD>
</TR>
<TR>
<TD>City:</TD><TD><input type="Text" name="city"></TD>
</TR>
<TR>
<TD>State:</TD><TD><input type="Text" name="state"></TD>
</TR>
<TR>
<TD>Country:</TD><TD><input type="Text" name="countrey"></TD>
</TR>
<TR>
<TD>Zip Code:</TD><TD><input type="Text" name="zip"></TD>
</TR>
<TR>
<TD>Birth Date</TD><TD><input type="Text" name="birthday"></TD>
</TR>
<TR>
<TD>Gender:</TD><TD><input type="Text" name="gender"></TD>
</TR>
<TR>
<TD>Secret Question:</TD><TD><input type="Text" name="squestion"></TD>
</TR>
<TR>
<TD>Secret Answer:</TD><TD><input type="Text" name="sawnser"></TD>
</TR>
<TR>
<TD colspan="2"><center><input type="Submit" name="submit" value="Enter information"></center></TD>
</TR>
</form>

  <?php
 // end if

?>

</body>
</html>
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back