Jump to content

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]
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)
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]
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"
[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?
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'].
[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.
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]
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?
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]
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.
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
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.