PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,439 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,481 people online right now. Registration is fast and FREE... Join Now!




Register Process Help

 

Register Process Help, Help

daniel0005

3 Jul, 2009 - 01:30 PM
Post #1

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
I started making a browser based game with php and i keep getting errors with my register process code. and i dont know what to do to fix them.. heres the code:

CODE
<?php
include('connect.php');


//Check if username is alphanumberic
$test=$_POST['username'];

if(!eregi ("([^A-Za-z0-9])",$test)){

//look for duplicate names
$query="SELECT * FROM users WHERE username ='$_POST['username']'";
$result=mysql_query($query);
$num=mysql_num_rows(&result);
if ($num == 0){

//Look for duplicate email
$query2="SELECT * FROM users WHERE email = '$_POST['email']'";
$result2=mysql_query($query2);
$num2 = mysql_num_rows($result2);

if($num2==0){

//if emails and passwords match up
if(($_POST['password']==$_POST['password2'])&&($_POST['email']==$_POST['email2'])){

//Generate Random Confirmation Code
$confirm_code=md5(uniqid(rand()));

//get rid of all html from hackers
$name=strip_tags($_POST['username']);
$email=strip_tags(&_POST['email']);
$pass=strip_tags($_POST['password']);

//insert data into database
$sql="INSERT INTO temp SET code='$confirm_code', username='$name', password='$pass', email='$email'";
$result=mysql_query($sql);

if($result){

$message="Your Confirmation Link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.slavestothegame.net/tbg/confirmation.php?passkey=$confirm_code";

$sentmail=main("$email",'Registration Confirmed',"$message");
header("Location:thankyou.html");

}else{
echo "Email was not able to send";
}

}else{
header("Location:emailandpasswordmatch.html");
}

}else{
header("Location:emailinuse.html");
}

}else{
header("Location:nameinuse.html");
}

}else{
header("Location:invalidname.html");
}

?>


User is offlineProfile CardPM
+Quote Post


TTechGuy

RE: Register Process Help

3 Jul, 2009 - 01:38 PM
Post #2

D.I.C Head
**

Joined: 24 Apr, 2009
Posts: 57



Thanked: 3 times
My Contributions
What's the error you receive?
User is offlineProfile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 02:08 PM
Post #3

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
I get this
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\xampp\htdocs\registernext.php on line 11
User is offlineProfile CardPM
+Quote Post

TTechGuy

RE: Register Process Help

3 Jul, 2009 - 02:47 PM
Post #4

D.I.C Head
**

Joined: 24 Apr, 2009
Posts: 57



Thanked: 3 times
My Contributions
The problem may be in the
CODE

$query="SELECT * FROM users WHERE username ='$_POST['username']'";


try assigning the $_POST variable to another variable before this so that the query doesn't have the extra ' marks around username. That may be the issue, but I'm not sure.

If it is, you will have the error again on the next query.
User is offlineProfile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 03:09 PM
Post #5

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
thanks that worked but now i get a new error

CODE
if (isset($email2))
{
    header("Location:thankyou.html");
}else{
    echo "click the button to confirm your email address";
}


It Says Syntax Error Unexpected T_IF

its on the line with the if (insset($email2))
User is offlineProfile CardPM
+Quote Post

TTechGuy

RE: Register Process Help

3 Jul, 2009 - 06:49 PM
Post #6

D.I.C Head
**

Joined: 24 Apr, 2009
Posts: 57



Thanked: 3 times
My Contributions
I would look before the if statement. The error says that it didn't expect to run into an IF statement. Maybe you didn't close a previous brace or maybe you forgot a semi colon.

Check it out.
User is offlineProfile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 08:20 PM
Post #7

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
CODE
$sendmail = mail($email, 'Registration Confirmed', $message, "From: Webmaster@Slavestothegame.net";


Now i get a error saying Unexpected ';'
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: Register Process Help

3 Jul, 2009 - 08:29 PM
Post #8

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
QUOTE
$sendmail = mail($email, 'Registration Confirmed', $message, "From: Webmaster@Slavestothegame.net";


you didn't closed Parentheses ()
php
$sendmail = mail($email, 'Registration Confirmed', $message, "From: Webmaster@Slavestothegame.net"); 

User is online!Profile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 08:33 PM
Post #9

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
QUOTE(daniel0005 @ 3 Jul, 2009 - 08:20 PM) *

CODE
$sendmail = mail($email, 'Registration Confirmed', $message, "From: Webmaster@Slavestothegame.net";


Now i get a error saying Unexpected ';'


Never mind about that i get a error :
syntax error unexpected ")" expecting T_PAAMAYIM_NEKUDOTAYIM

in this code:
CODE
if (isset(confirm_email))


once again i figured that out too sorry
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: Register Process Help

3 Jul, 2009 - 09:13 PM
Post #10

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
glad to you solved your problem.
User is online!Profile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 11:14 PM
Post #11

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
sorry about all the problems with my code heres a new one:

It wont send the emails to my email...

CODE
$sql="INSERT INTO temp SET code='$confirm_code', username='$name', password='$pass', email='$email'";
$result=mysql_query($sql);

if($result){

$message="Your Confirmation Link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.slavestothegame.net/tbg/confirmation.php?passkey=$confirm_code";

$sendmail = mail ($email, 'Registration Confirmed', $message, $adminemail);

User is offlineProfile CardPM
+Quote Post

noorahmad

RE: Register Process Help

3 Jul, 2009 - 11:23 PM
Post #12

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
are you uploading your file to a server i mean you need server you can't send it form your local server?

Basic
Send Email Using PHP (SMTP Direct)
User is online!Profile CardPM
+Quote Post

daniel0005

RE: Register Process Help

3 Jul, 2009 - 11:38 PM
Post #13

New D.I.C Head
*

Joined: 19 Dec, 2007
Posts: 9


My Contributions
QUOTE(noorahmad @ 3 Jul, 2009 - 11:23 PM) *

are you uploading your file to a server i mean you need server you can't send it form your local server?

Basic
Send Email Using PHP (SMTP Direct)

Yeah im on my own Xampp server it says that its working.. it goes through it all to the thank you page heres the code for that section:

CODE

$sql="INSERT INTO temp SET code='$confirm_code', username='$name', password='$pass', email='$email'";
$result=mysql_query($sql);

if($result){

$message="Your Confirmation Link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.slavestothegame.net/tbg/confirmation.php?passkey=$confirm_code";

$sendmail=mail($email, 'Registration Confirmed', $message, $adminemail);

if (isset($sendmail))
{
header('Location:thankyou.html');
}
else
{
echo "click the button to confirm your email address";
}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:06AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month