Jump to content

write to SQL table not working.


adzi

Recommended Posts

Hi,

I'm pretty new to the whole PHP coding side of websites. I'm trying to create a very simple, very basic members login system for my website where only registered members can access. It doesnt have to be 100% secure at the moment as that's what Im looking to improve but I cant seem to get the fundamentals sorted.

 

This is my register.html code, with a simple form capturing the data.

<form name="register" method="post" action="register.php">
<input name="register_name" type="text" value="username" size="20"/><br>
<input name="register_password" type="password" value="password" size="20"/><br>
<input name="password_reminder" type="text" value="password reminder" size="20"/><br>
<input name="register_email" type="text" value="email" size="50"/><br>
<input type="submit" name="submit" value="submit"/>
<input type="reset" name="reset" value="reset"/>
</form>

 

Here's my register.php page thats called when the submit button is hit.

<?php
$register_name = $_POST['register_name'];
$register_password = $_POST['register_password'];
$register_email = $_POST['register_email'];
$password_reminder = $_POST['password_reminder'];

@mysql_connect("localhost", "My Database User", "My database password") or die("Cannot connect to database.");
@mysql_select_db("centrest_members") or die("Cannot select database");
$insert = mysql_query("insert into users values ('NULL','".addslashes($register_name)."', 
'".sha1($register_password)."','".$password_reminder."','".$register_email."')")
or die("Could not insert data because ".mysql_error());
?>

 

I get the error,

Parse error: syntax error, unexpected T_VARIABLE in /home/centrest/public_html/adzi/register.php on line 2

 

Can anyone help as to why this is happening?

 

Thanks,

Adzi

 

Edit:

 

This is my SQL table structure;

 

id smallint(6) auto_increment               
register_name varchar(15)                 
register_password varchar(20)                 
register_email varchar(50)              
password_reminder varchar(30)

             

 

 

Link to comment
Share on other sites

See if renaming it helps

 

$register_name = $_POST['register_name'];

 

to

 

$name = $_POST['name'];

 

and change your form and sql statement to match.

 

Echo the $_POST variable to see its data.

 

Try having data instead of the $_POST variable, like

 

$register_name = "hi";

 

Using a normal text editor?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.