Jump to content

SignUp script help


poetichotline

Recommended Posts

I've created the following sign up script for my website.  It, however, is giving me an error equal to

Parse error: syntax error, unexpected T_STRING in /home/poetgos7/public_html/signupck.php on line 32.  I've tried to fix it, and nothing I seem to do works.  Any ideas? 

 

 

<?php 
include('layout.inc');
?>
<div style="position:absolute; top:110; left:252; width:500; height:300; z-index:1;">
<p>
<?
$servername= localhost;
$dbusername = poetgos7_poetic;
$dbpassword = poetic;
$dbname = poetgos7_users;

$connection = mysql_connect($servername, $dbusername, $dbpassword);
$db = mysql_select_db($dbname, $connection);

$name = $_POST[username];
$password = $_POST[password];
$password2 = $_POST[password2];
$email = $_POST[email];
$ip = $_POST[ip];

//if else (else if)
if($name == false || $password == false || $password2 == false || $email == false){
echo "You did not fill out all the required fields.  Please hit the back button and try again!";
}
if ($password != password2){
echo "The passwords did not match!  Please hit the back button and try again!";
}else{
$connection = mysql_connect($servername, $dbusername, $dbpassword);
$db = mysql_select_db($dbname, $connection);
$sql = "INSET INTO members (username, password, email, ip) VALUES ($username, $password, $email, $ip);
$result = mysql_query($sql);
echo "Thank you for your registration to poetichotline.org!";
}
?>
</div>

Link to comment
Share on other sites

try this:

 

<?php 
include('layout.inc');
?>

<div style="position:absolute; top:110; left:252; width:500; height:300; z-index:1;">
<p>
<?php
$servername= "localhost";
$dbusername = "poetgos7_poetic";
$dbpassword = "poetic";
$dbname = "poetgos7_users";

$connection = mysql_connect($servername, $dbusername, $dbpassword);
$db = mysql_select_db($dbname, $connection);

$name = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$ip = $_POST['ip'];

//if else (else if)
if($name == false || $password == false || $password2 == false || $email == false){
echo "You did not fill out all the required fields.  Please hit the back button and try again!";
}
if ($password != password2){
echo "The passwords did not match!  Please hit the back button and try again!";
}else{
$connection = mysql_connect($servername, $dbusername, $dbpassword);
$db = mysql_select_db($dbname, $connection);
$sql = "INSERT INTO members (username, password, email, ip) VALUES ($username, $password, $email, $ip)";
$result = mysql_query($sql);
echo "Thank you for your registration to poetichotline.org!";
}
?>
</div>

Link to comment
Share on other sites

It looks like you misspelled "INSERT" in query, that's all I could find though.

 

Also, just a suggestion, I would change the username / password of your database as you showed us the username, password, database name and domain name of your site, it is probably easily hackable w/ all of that info.

 

While I wouldn't do this, other not so nice people may.

 

Also, right now I could post some nasty SQL as my name, or any other field and really screw w/ your database. mysql_escape_string($_POST['field']) should take care of that. And you may want to consider a regex for email validation.

 

Link to comment
Share on other sites

This:

if ($password != password2){

 

Should be:

if ($password != $password2){

 

Thank you very much.... I can't believe I missed that.  Guess that's why you shouldn't try to code at 2:00 am in the morning uh?  lol

 

On a side note:  for some reason the }else{ statement does not carry through.  There is no error message, but when I execute the page it displays the message "Thank you for registering" whether or not everything is filled in correctly, and it dosn't add the database.  any idea?

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.