Will not add data to DB

Status
Not open for further replies.

elliott1

New Member
Messages
31
Reaction score
0
Points
0
i have created a script to create users see below , it runs fine and says it has registed but when going in the table it adds the username and password but its just blank:dunno:

PHP:
<?php
include ("config.php");
////////////////////////////////////////
////// DONOT EDIT BELOW /////////
///////////////////////////////////////
//
// Connect to server and select databse.
mysql_connect("$server", "$db_user", "$db_pass")or die("cannot connect"); 
mysql_select_db("$mysql_database")or die("cannot select DB");
// select the database or table?
mysql_select_db("elliott1_Members")
or die ("Could not select database because ".mysql_error());
// insert the data
$insert = mysql_query("insert into $table values ('ID INT', '".$_POST['Username']."',
'".$_POST['Password']."')")
or die("Could not insert data because ".mysql_error());
// print a success message
echo "Your user account has been created!<br>"; 
echo "Now you can <a href=main_login.html>log in</a>";
?>
Thanks :biggrin:

EDIT: When i changed the table it says :

ALTER TABLE `Members` ADD UNIQUE (
`ID`
)

I dont think i have done that right , thanks
Edit:
any one ????????????????????:biggrin:
 
Last edited by a moderator:

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
Please provide your signup script. I'm guessing you forgot to wrap the entry fields with the code:
HTML:
<form method="post" action="whateverthatfileis.php"></form>
 
Last edited:

elliott1

New Member
Messages
31
Reaction score
0
Points
0
oh rite :nuts: am kinda new to this i dont even think my script has that form post

HTML:
<?
<html>
<head>
<title>Register to Elliotts Website</title>
</script>

</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<table border='0' width='50%' cellspacing='0' cellpadding='0' align=center><form name=form1 method=post action=NEWCHECK.php onsubmit='return validate(this)'><input type=hidden name=todo value=post>
<tr bgcolor='#C3FDB8'><td align=center colspan=2><font face='Verdana' size='2' ><b>Signup</b></td></tr>
<tr bgcolor='#C3FDB8'><td >&nbsp;<font face='Verdana' size='2' >Username</td><td ><font face='Verdana' size='2'><input type=text name=username></td></tr>
<tr bgcolor='#C3FDB8'><td >&nbsp;<font face='Verdana' size='2' >Password</td><td ><font face='Verdana' size='2'><input type=password name=password></td></tr>
<tr bgcolor='#C3FDB8'><td align=center colspan=2><input type=submit value=Signup></td></tr>
</table>
<center>
 
<a href="login.html" /a>Already a member? Please Login</a></font></center> 
<center>

</body>
</html>

Thanks!
 
Last edited by a moderator:

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
I really think you need to Google a PHP\MySQL tutorial. We are here to support you with your hosting account, not fix your PHP scripts.

I do not mind helping every once in a while if you get REALLY stuck but just from looking at this I can tell you spent no more than 5 minutes looking for an answer.

It is very simple to create a form that submits data and there are TONS of tutorials online for it. Please search before coming here asking for help.

-Corey
 

elliott1

New Member
Messages
31
Reaction score
0
Points
0
i have done that , the above script is from 2 or 3 websites :drool:
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
Whenever you have something in <> and it has attributes, such as:
HTML:
<form name=>
you must use "" to define the attributes, like this:
HTML:
<form name="i_like_pizza">
you can't just say
HTML:
<form name=blah>
because that's not valid and it won't do anything.
 
Last edited:

elliott1

New Member
Messages
31
Reaction score
0
Points
0
:biggrin: thanks everyone finally got it working , i changed the above script it was abit crapy :thefinger


thanks again :biggrin:
 
Status
Not open for further replies.
Top