Jump to content

Clueless


catelee2u

Recommended Posts

I'm trying to make a registration page that will submit the users details to my database. I am very new to php and mysql and don't know a lot of commands yet but trying to learn. I have written what I expected to work but am getting output :

Parse error: syntax error, unexpected $end in /var/www/sendregister.php on line 57 (the last line)

I tried getting rid of some white space hearing that can be troublesome but it still does it.

 

I have

registration.php (my form)

<form action="sendregister.php" method="post">

First Name :<br />

<input type="text" name="fname" /><br /><br />

Last Name  :<br />

<input type="text" name="sname" /><br /><br />

Contact Email :<br />

<input type="text" name="email" /><br /><br />

Desired Username :<br />

<input type="text" name="loginname" /><br /><br />

Password :<br />

<input type="text" type="hidden" name="loginpwd" /><br /><br/>

Verify Password :<br />

<input type="text" type="hidden" name="loginpwd2" /><br /><br />

Check box to agree to our terms <input type="checkbox" name="check" value="agree" /><br />

<a href="terms.php" alt="Terms">Terms</a><br/><br />

<input type="submit" name="register" value="register" />

</form>

 

and the code page supposed to handle form input

sendregister.php

<?php

// Connect to Database

$con = mysql_connect("localhost","username","password");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

//If form is submitted this runs

if (isset ($_POST['register'])) {

 

//Check for empty form fields

if (!$_POST['fname'] || !$_POST['sname'] || !$_POST['email'] || !$_POST['loginname'] ||

!$_POST['loginpwd'] || !$_POST['loginpwd2']) {

die('You did not complete all of the required fields');

}

 

//Check checkbox here

if (!isset ($_POST['register']))

{

die('You did not agree to our terms');

}

 

//Check if login name taken

mysql_select_db("shadow", $con);

$potential = $_POST['loginname'];

$result = ("SELECT loginname FROM members WHERE loginname = '$potential'");

$finalresult = mysql_num_rows($result);

If ($finalresult != 0 ) {

die ('Your desired username '.$_POST['loginname'].' is already taken - please choose another.');

}

 

//Check passwords match

$pwd1 = $_POST['loginpwd'];

$pwd2 = $_POST['loginpwd2'];

If ( $pwd1 != $pwd2 ) {

die ('Your passwords do not match.');

}

 

//Check password is alphanumeric

$alphanumeric = $_POST['loginpwd'];

If (!ctype_alnum($alphanumeric)){

die('Your password must only contain letters and numbers');

}

 

//Encrypt passwords and insert to database

$_POST['loginpwd'] = md5($_POST['loginpwd']);

mysql_query("INSERT INTO members (fname, sname, email, loginname, loginpwd) VALUES ('$_POST[fname]', '$_POST[sname]', '$_POST', '$_POST[loginname]', '$_POST[loginpwd]')");

 

//include registration congrats page onto this page

 

include("registered.php");

 

//close database

 

mysql_close($con);

?>

 

I have looked through this and don't know what problems there are with it though I suspect there is more than one.

 

Thankyou in advance for any assistance,

Catherine

Link to comment
https://forums.phpfreaks.com/topic/179294-clueless/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.