...

View Full Version : problem inserting form info into mysql database



gkelly
09-20-2005, 04:21 PM
<form method=\"post\" action=?=$PHP_SELF">
<pre>
<?php if(!$username|| !$pass || !$pass2 || !$email)
echo "Please fill out all fields";
echo "<br>";
<br>
Username:
<input type="text" name="uname" size="15" value="<?php echo $username?>">
<br>Password:
<input type="text" name="email" size="30"><br>
<input type="submit" name="submit" value="submit">
<pre>
<br>
Username:
<input type="text" name="uname" size="15" value="<?php echo $username?>">
<br>Password:
<input type="text" name="email" size="30"><br>
<input type="submit" name="submit" value="submit">
</pre>


</form>

</body>

</html>
<?php

$db= mysql_connect("localhost","root","");
mysql_select_db("kgazette");

if($submit) {
$query=("insert users uname,passwd,email values ('$uname','$passwd','$email')");
mysql_query($query);
$result=mysql_query($query);
echo "You are now registered";
} else {
echo "There was some problems with your Registration form please contact your Ad
ministrator";
}
?>

NancyJ
09-20-2005, 04:24 PM
A couple of hints - use the [ PHP ] tags around your code - it makes it easier to read, and secondly, try explaining the problem rather than just posting the code, along with any error messages you are getting.

I think the problem is this line :


$query=("insert users uname,passwd,email values ('$uname','$passwd','$email')");

change it to
$query=("INSERT INTO users (uname,passwd,email) VALUES ('$uname','$passwd','$email')")or die(mysql_error());

gkelly
09-20-2005, 05:17 PM
Thanks for the quick response, now the problem I am having is it inserts only one record if, I go to the screen and try to create another user, it will not insert another user any ideas.

NancyJ
09-20-2005, 06:44 PM
are you getting any error messages?
Are you trying to insert a record with the same values in a 'unique' field?

gkelly
09-20-2005, 07:03 PM
Thanks for all your help I figured out the problem it was just that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum