Jump to content


Photo

i cant find my error in my register.php in notepad :(


  • Please log in to reply
29 replies to this topic

#1 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 03:40 AM

ok heres the code tell me if there is an error :(

<?php
echo("
	<center>
	<form method=\"POST\">
	Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
	Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
	Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
	Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br />
	<input name=\"register\" type=\"submit\" value=\"Register\">
	</form>
	</center>
");
if($_POST[submit])
{
	$username = $_POST[username];
	$password = $_POST[pass];
	$cpassword = $_POST[cpass];
	$email = $_POST[email];
	if($pass==$cpass) {
		$password = md5($password);
		$checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());
		$checkname= mysql_num_rows($checkname) or die(mysql_error());
		$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error());
		$checkemail = mysql_num_rows($checkemail) or die(mysql_error());
		if ($checkemail>0|$checkname>0) {
			echo "The username or email is already in use";
		}else{
			$username = htmlspecialchars($username);
			$password = htmlspecialchars($password);
			$email = htmlspecialchars($email);
			$query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());
			$getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error());
			$user = mysql_fetch_array($getuser) or die(mysql_error());
			$profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error());
			echo "You have successfully registered!";
		}
	}else{
		echo("Your passwords don't match!");
	}
}
?>


#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 03:46 AM

how about YOU tell US what's wrong.  is it not submitting, is it not processing, do you get a parse error, is it a blank page?  what's the issue?

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 03:46 AM

What you mean is there an error you tell us!

Sort out your form!


loads or errors man dam lol......................

<form method="post" action"">// this is minium

//another
if($_POST['submit']){

code
}

about a 30 of them lol............
are you blind weres the $_POST['   '];
man.

what the hell is this about lol.....bad code pratice ok.

if ($checkemail>0|$checkname>0)
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 03:47 AM

Dude, yea. Tell us what error you get.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#5 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:13 AM

its just not sending srry for the late replay i was playing cs lol
by saying sending sending to the database

#6 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:18 AM

dude it works without the ' '
i have built this page b4 but now its now working
i didnt build the exact page tho

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 04:19 AM

i have know read your code and pointed out a lot nearly all lol..........
but you continue to give advice make me laugh change all that i ask ok.

ps. you was also advised to use session ok try them, the $_SESSION code is better then the cookie code your using ok.

<?php

//This dosent need echoing 1 problam you can use html then start php.
echo("
	<center>//This needs table html problam agin.

	<form method=\"POST\">// This form is incorrect look up forms.

	Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
	Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
	Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
	Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br />
	<input name=\"register\" type=\"submit\" value=\"Register\">
	</form>
	</center>
");
if($_POST[submit])//this is wrong first the sytex wrong secondly you got the name wrong its called register as set in your form $_POST['register']
{

All the $_POST[' '] wrong all need single quotes. 

	$username = $_POST[username];
	$password = $_POST[pass];
	$cpassword = $_POST[cpass];
	$email = $_POST[email];


	if($pass==$cpass) {

		$password = md5($password);

// your doing a double sql statement when you can use one......

		$checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());

		$checkname= mysql_num_rows($checkname) or die(mysql_error());
		$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error());
		
// dont like this bad code pratice to use this sort of valadating code change it.

$checkemail = mysql_num_rows($checkemail) or die(mysql_error());
		if ($checkemail>0|$checkname>0) {


			echo "The username or email is already in use";
		}else{


// where the addslashes example name=addslashes($name);

			$username = htmlspecialchars($username);
			$password = htmlspecialchars($password);
			$email = htmlspecialchars($email);



			$query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());

// Dont know why this here!

$getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($getuser) or die(mysql_error());


			$profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error());
			echo "You have successfully registered!";
		}
	}else{
		echo("Your passwords don't match!");
	}
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:21 AM

lol
all of this is inside of a table on my site just didnt want to post all that its long

#9 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:26 AM

man ur script is too long and confusing maybe if u would put it in the bbcode for code
it would look a lot better and use the tabs better u have to tab everything inside the if then if there is another if then tab all of it too lol


#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 04:32 AM

For a man that gives others advice you havenot seen why you can not post joke.


you got post submit and called it register why?
if($_POST['register'] {

}
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:36 AM

ok i think i got it now first the validations werent right then the submit problem

i made this code first off a tutorial then off my old site so thats why i just started really making database driven sites but i all clicks in my head fast'

NOTE: "Why is my karma so bad i don't get it i had +1 -1 now i have -2"

#12 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:42 AM

<?php
echo("
	<center>
	<form method=\"POST\">
	Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
	Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
	Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
	Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br />
	<input name=\"register\" type=\"submit\" value=\"Register\">
	</form>
	</center>
");
if($_POST[register])
{
	$username = $_POST[username];
	$password = $_POST[pass];
	$cpassword = $_POST[cpass];
	$email = $_POST[email];
	if($password==$cpassword) {
		$password = md5($password);
		$checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());
		$checkname= mysql_num_rows($checkname) or die(mysql_error());
		$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error());
		$checkemail = mysql_num_rows($checkemail) or die(mysql_error());
		if ($checkemail>0|$checkname>0) {
			echo "The username or email is already in use";
		}else{
			$username = htmlspecialchars($username);
			$password = htmlspecialchars($password);
			$email = htmlspecialchars($email);
			$query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());
			$getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error());
			$user = mysql_fetch_array($getuser) or die(mysql_error());
			$profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error());
			echo "You have successfully registered!";
		}
	}else{
		echo("Your passwords don't match!");
	}
}
?>

this is what i have post the fixed version plz

EDIT: why do u hate me redarrow?

#13 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 04:44 AM

in case you didn't catch what the problem was in the first place, you hadn't set an action="" attribute for the <form> tag.  it had no idea where to submit the form.

EDIT: my mistake on that one, thanks thorpe.

are you getting no echoing at all after the form is submit?  and you have it right the first time, the name of the submit button is "register" so it sends $_POST['register'], not $_POST['submit'].

#14 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 July 2006 - 04:53 AM

in case you didn't catch what the problem was in the first place, you hadn't set an action="" attribute for the <form> tag.  it had no idea where to submit the form.

action nor method are both not required in a form. By default, action will send back to itself, by default, method will be GET.

#15 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 04:55 AM

thank u dude action is a cgi i dont use cgi and i find it funny i have 10 other working pages with out the action field and they work fine

#16 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 July 2006 - 04:57 AM

action is a cgi

That makes no sense. You can point your action toward a .php script, not just cgi. It just happens to be that without an action, the form will submit to itself.

#17 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:03 AM

ok if u guys think its such a great idea to put an action in tell the exact code to put in plz


EDIT:

ok heres the latest code plz help

<?php
echo("
	<center>
	<form method=\"POST\">
	Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\" /><br />
	Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\" /><br />
	Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\" /><br />
	Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"email\" /><br />
	<input name=\"submit\" type=\"submit\" value=\"Register\" />
	</form>
	</center>
");
if($_POST['submit'])
{
	$username = $_POST['username'];
	$password = $_POST['pass'];
	$cpassword = $_POST['cpass'];
	$email = $_POST['email'];
	if($password==$cpassword) {
	        $password = md5($password);
		$checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());
		$checkname= mysql_num_rows($checkname) or die(mysql_error());
		$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error());
		$checkemail = mysql_num_rows($checkemail) or die(mysql_error());
		if ($checkemail>0|$checkname>0) {
			echo "The username or email is already in use";
		}else{
			$username = htmlspecialchars($username);
			$password = htmlspecialchars($password);
			$email = htmlspecialchars($email);
			$query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());
			$getuser = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
			$user = mysql_fetch_array($getuser) or die(mysql_error());
			$profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error());
			echo "You have successfully registered!";
		}
	}else{
		echo("Your passwords don't match!");
	}
}
?>


#18 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 05:09 AM

perhaps you should review your HTML knowledge before you dive right into PHP programming.

<form action="pagetosendtheforminfoto.php" method="post">
</form>

regardless, you're still not answering the question we need to know:  are you getting NOTHING being echoed to the page, is the submit button not doing anything, are you not getting registered, or what?

#19 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:15 AM

see thats the prob i dont want to send it to anything and i know html but i dont send the form to a page in html either srry

#20 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:20 AM

ok here is the problem i posted it already but here it is:

The information doesn't go to the database.

heres is the codeing:

<?php
echo("
	<center>
	<form method=\"POST\">
	Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\" /><br />
	Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\" /><br />
	Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\" /><br />
	Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"email\" /><br />
	<input name=\"submit\" type=\"submit\" value=\"Register\" />
	</form>
	</center>
");
if($_POST['submit'])
{
	$username = $_POST['username'];
	$password = $_POST['pass'];
	$cpassword = $_POST['cpass'];
	$email = $_POST['email'];
	if($password==$cpassword) {
	        $password = md5($password);
		$checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());
		$checkname= mysql_num_rows($checkname) or die(mysql_error());
		$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error());
		$checkemail = mysql_num_rows($checkemail) or die(mysql_error());
		if ($checkemail>0|$checkname>0) {
			echo "The username or email is already in use";
		}else{
			$username = htmlspecialchars($username);
			$password = htmlspecialchars($password);
			$email = htmlspecialchars($email);
			$query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());
			$getuser = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
			$user = mysql_fetch_array($getuser) or die(mysql_error());
			$profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error());
			echo "You have successfully registered!";
		}
	}else{
		echo("Your passwords don't match!");
	}
}
?>

EDIT: if you want to see the page in action then heres the link:

http://dreamshowstud...et/register.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users