Jump to content

Archived

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

BillyBoB

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

Recommended Posts

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

[code]
<?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!");
}
}
?>
[/code]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
its just not sending srry for the late replay i was playing cs lol
by saying sending sending to the database

Share this post


Link to post
Share on other sites
dude it works without the ' '
i have built this page b4 but now its now working
i didnt build the exact page tho

Share this post


Link to post
Share on other sites
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.
[code]

<?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!");
}
}
?>
[/code]

Share this post


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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'] {

}

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
[code]
<?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!");
}
}
?>
[/code]

this is what i have post the fixed version plz

EDIT: why do u hate me redarrow?

Share this post


Link to post
Share on other sites
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'].

Share this post


Link to post
Share on other sites
[quote]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.[/quote]
action nor method are both not required in a form. By default, action will send back to itself, by default, method will be GET.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[quote]action is a cgi[/quote]
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.

Share this post


Link to post
Share on other sites
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

[code]
<?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!");
}
}
?>
[/code]

Share this post


Link to post
Share on other sites
perhaps you should review your HTML knowledge before you dive right into PHP programming.

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

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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:

[code]
<?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!");
}
}
?>
[/code]

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

[url=http://dreamshowstudios.net/register.php]http://dreamshowstudios.net/register.php[/url]

Share this post


Link to post
Share on other sites
youve got an error with your mysql_fetch_array() is my guess.  its die()ing, but there is no mysql_error() since the previous query went off fine.  it's just not a valid resource.  try removing the or die() from the mysql_fetch_array() and you might find something.

if you need the ID that MySQL auto-inserted in the previous query, use mysql_insert_id().  don't grab it from the database, as that wastes resources.

Share this post


Link to post
Share on other sites
ok though all ur i dont like this section of coding i have found the error since most of this coding wasnt updated for the new databases i hadnt made the script check the emails in the profile srry for the big mess
and will someone plz tell me why my karma is bad plz

Share this post


Link to post
Share on other sites
why dont you do

$password = md5($_POST['pass']);

instead of

$password = $_POST[pass];
and remove:
$password = md5($password);

Share this post


Link to post
Share on other sites

×

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.