Jump to content

Why is my registration page not working?


austinthompson

Recommended Posts

I have a script where people can register to use my site but it does not work.  I did not write this script I downloaded it. I thought I fixed it but it does not work no matter what I do. I am uploading the original unedited version of this page in case a modification I made is part of the problem. Thanks.

17230_.php

Link to comment
Share on other sites

this is what i would do my code may not be the best, but it works. There is still alot of styling to be done. Hope it helps!

 

<?php
//connect to your database
$connection = mysql_connect("localhost","user","password");
if (!$connection)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  
//message if query successful
$message= $_GET['m'];
if ($message == "1"){


//select query and choose database
mysql_select_db("database", $connection);

$result = mysql_query("SELECT * FROM people WHERE admin=1");

while($row = mysql_fetch_array($result))
  {
  $to = $row['email'].",";
  


//post variables
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$suffix = $_POST['suffix'];
$userid = $_POST['userid'];
$email = $_POST['email'];
$comment= $_POST['comment'];


//send the emails

$subject = "Request for new WishList account";
$message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$message,$headers);
  }
//echo content
echo "<h2>Thank you. You should receive an email shortly with your account details</h2>" ;

}else {

//main form
echo 
'<HTML>

<link rel=stylesheet href=style.css type=text/css>

<title>Sign Up </title>
<BODY>
<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>

<td valign="top">
"<center>"
The following information will be submitted to the administrator of
the WishList Site who will create an account for you.  You will
receive an email with your WishList password when the account is
created.

</td></tr></table>
<p> 
<form method=post action="registerUser.php?m=1">
<table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow>

<tr><td colspan="2" align="center" bgcolor="#6702cc">
<font size=3 color=white><b>Please Fill In</b></font>
</td></tr>
<tr>
<td align=right><b>First Name</b></td>
<td><input type=text name=fname size=20></td>
</tr>
<tr>
<td align=right><b>Last Name</b></td>
<td><input type=text name=lname size=20></td>
</tr>
<tr>
<td align=right><b>Suffix</b></td>
<td><input type=text name=suffix size=20></td>
</tr>
<tr>
<td align=right><b>Desired Userid</b></td>
<td><input type=text name=userid size=20></td>
</tr>

<tr>
<td align=right><b>Email</b></td>
<td><input type=text name=email size=40></td>
</tr>

<tr>
<td align=right><b>Comment</b></td>
<td><textarea name=comment rows=3 cols=60></textarea></td>
</tr>

<tr><td align="center" colspan="2" bgcolor="#c0c0c0">
<input type="submit" value="Submit" style="font-weight:bold">

</td></tr>
</table>

</form>

"</center>"
</td>
</tr>
</table>
</body>
</html>';







}



?>

Link to comment
Share on other sites

The code abrahamgarcia27 posted doesn't actually register a user, it simply sends the user an email saying that an admin will register them shortly.

 

You will need to post a description of what your actual problem is (this doesn't work is not descriptive enough for us to be able to assist you). It's always best to post the relevant code directly within your post using


tags. People won't often download code.

Link to comment
Share on other sites

The code abrahamgarcia27 posted doesn't actually register a user, it simply sends the user an email saying that an admin will register them shortly.

 

You will need to post a description of what your actual problem is (this doesn't work is not descriptive enough for us to be able to assist you). It's always best to post the relevant code directly within your post using


tags. People won't often download code.

 

Sorry. Super noob mistake.

 

Ok, let me try this again. 

 

The code I have displays what you see here: http://www.alliwantfor.me/registerUser.php

 

That is the first problem. There is no way to register because it tells you "Too many requests have been made within the last hour. This feature has been temporarily disabled."

 

If I delete the part of the code that displays that statement then it appears to work correctly and gives you a form. That form does nothing once submitted. That version is located at: http://www.alliwantfor.me/fix.php

 

Here is the original code found at: http://www.alliwantfor.me/registerUser.php

 

<?php

$ignoreSession = true;

include "funcLib.php";

$stop = true;
?>

<HTML>

<head>

<link rel=stylesheet href=style.css type=text/css>

<title>Sign Up </title>

</head>

<BODY>

<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>

<td valign="top">
<center>
<?php

if($_REQUEST["fname"] != ""){
if($stop){
  return;                      
}
  $fname = convertString($_REQUEST["fname"]);
  $lname = convertString($_REQUEST["lname"]);
  $suffix = convertString($_REQUEST["suffix"]);
  $userid = convertString($_REQUEST["userid"]);
  $email = convertString($_REQUEST["email"]);
  $comment = convertString($_REQUEST["comment"]);

  // send an email out to all the admins
  $query = "select * from people where admin=1";
  $result = mysql_query($query) or die("Could not query: " . mysql_error());  

  $to = "";

  while($row = mysql_fetch_assoc($result)){
    $to .= $row["email"] . ",";
  }

  $subject = "Request for new WishList account";
  $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;

  $result = sendEmail($to, "", $subject, $message, 0);

  if($result == 1)
    print "<h2>Thank you. You should receive an email shortly with your account details</h2>";
  else
    print "<h1>An unexpected error has occured</h1>";

}
else{ 
?>
<h2>Welcome to the WishList Site</h2>

<table width=80%><tr><td align=left> 

<?php
if($stop){
  print "Too many requests have been made within the last hour.  This feature has been temporarily disabled.";
  return;
}
?>
The following information will be submitted to the administrator of
the WishList Site who will create an account for you.  You will
receive an email with your WishList password when the account is
created.

</td></tr></table>
<p> 
<form method=post action="registerUser.php">
<table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow>

<tr><td colspan="2" align="center" bgcolor="#6702cc">
<font size=3 color=white><b>Please Fill In</b></font>
</td></tr>
<tr>
<td align=right><b>First Name</b></td>
<td><input type=text name=fname size=20></td>
</tr>
<tr>
<td align=right><b>Last Name</b></td>
<td><input type=text name=lname size=20></td>
</tr>
<tr>
<td align=right><b>Suffix</b></td>
<td><input type=text name=suffix size=20></td>
</tr>
<tr>
<td align=right><b>Desired Userid</b></td>
<td><input type=text name=userid size=20></td>
</tr>

<tr>
<td align=right><b>Email</b></td>
<td><input type=text name=email size=40></td>
</tr>

<tr>
<td align=right><b>Comment</b></td>
<td><textarea name=comment rows=3 cols=60 onfocus="this.value=''"></textarea></td>
</tr>

<tr><td align="center" colspan="2" bgcolor="#c0c0c0">
<input type="submit" value="Submit" style="font-weight:bold">

</td></tr>
</table>

</form>

</center>
</td>
</tr>
</table>
</body>
</html>
<?php
   }
?>

 

Here is the code posted at: http://www.alliwantfor.me/fix.php

 

<?php

$ignoreSession = true;

include "funcLib.php";

$stop = true;
?>

<HTML>

<head>

<link rel=stylesheet href=style.css type=text/css>

<title>Sign Up </title>

</head>

<BODY>

<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>

<td valign="top">
<center>
<?php

if($_REQUEST["fname"] != ""){
if($stop){
  return;                      
}
  $fname = convertString($_REQUEST["fname"]);
  $lname = convertString($_REQUEST["lname"]);
  $suffix = convertString($_REQUEST["suffix"]);
  $userid = convertString($_REQUEST["userid"]);
  $email = convertString($_REQUEST["email"]);
  $comment = convertString($_REQUEST["comment"]);

  // send an email out to all the admins
  $query = "select * from people where admin=1";
  $result = mysql_query($query) or die("Could not query: " . mysql_error());  

  $to = "";

  while($row = mysql_fetch_assoc($result)){
    $to .= $row["email"] . ",";
  }

  $subject = "Request for new WishList account";
  $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;

  $result = sendEmail($to, "", $subject, $message, 0);

  if($result == 1)
    print "<h2>Thank you. You should receive an email shortly with your account details</h2>";
  else
    print "<h1>An unexpected error has occured</h1>";

}
else{ 
?>
<h2>Welcome to the WishList Site</h2>

<table width=80%><tr><td align=left> 

The following information will be submitted to the administrator of
the WishList Site who will create an account for you.  You will
receive an email with your WishList password when the account is
created.

</td></tr></table>
<p> 
<form method=post action="registerUser.php">
<table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow>

<tr><td colspan="2" align="center" bgcolor="#6702cc">
<font size=3 color=white><b>Please Fill In</b></font>
</td></tr>
<tr>
<td align=right><b>First Name</b></td>
<td><input type=text name=fname size=20></td>
</tr>
<tr>
<td align=right><b>Last Name</b></td>
<td><input type=text name=lname size=20></td>
</tr>
<tr>
<td align=right><b>Suffix</b></td>
<td><input type=text name=suffix size=20></td>
</tr>
<tr>
<td align=right><b>Desired Userid</b></td>
<td><input type=text name=userid size=20></td>
</tr>

<tr>
<td align=right><b>Email</b></td>
<td><input type=text name=email size=40></td>
</tr>

<tr>
<td align=right><b>Comment</b></td>
<td><textarea name=comment rows=3 cols=60 onfocus="this.value=''"></textarea></td>
</tr>

<tr><td align="center" colspan="2" bgcolor="#c0c0c0">
<input type="submit" value="Submit" style="font-weight:bold">

</td></tr>
</table>

</form>

</center>
</td>
</tr>
</table>
</body>
</html>
<?php
   }
?>

 

Hopefully this is a better explination.

 

Thanks for your help guys.

 

Link to comment
Share on other sites

this code will insert to a database as well as to send the email that there has been a new user registered

 

<?php
//connect to your database
$connection = mysql_connect("localhost","root","pass");
if (!$connection)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  
//message if query successful
$message= $_GET['m'];
if ($message == "1"){

//insert infomation to database
mysql_select_db("databse", $connection);

$sql="INSERT INTO people (fname, lname, suffix, userid, email, comment, admin)
VALUES
('$_POST[fname]','$_POST[lname]','$_POST[suffix]', '$_POST[userid]', '$_POST[email]' , '$_POST[comment]', '0')";

if (!mysql_query($sql,$connection))
  {
  die('Error: ' . mysql_error());
  }



//select query and choose database

$result = mysql_query("SELECT * FROM people WHERE admin=1");

while($row = mysql_fetch_array($result))
  {
  $to = $row['email'];
  }


//post variables
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$suffix = $_POST['suffix'];
$userid = $_POST['userid'];
$email = $_POST['email'];
$comment= $_POST['comment'];


//send the emails

$subject = "Request for new WishList account";
$message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$message,$headers);

//echo content
echo "<HTML>

<link rel=stylesheet href=style.css type=text/css>

<title>Sign Up </title>
<BODY>
<table cellspacing='0' cellpadding='5' width='100%' height='100%' bgcolor='#FFFFFF' nosave border='0' style='border: 1px solid rgb(128,255,128)'>
<tr>

<td valign='top'>
<center><h2>Thank you. You should receive an email shortly with your account details</h2>
</center>
</td>
</tr>
</table>
</body>
</html>" ;

}else {

//main form
echo 
"<HTML>

<link rel=stylesheet href=style.css type=text/css>

<title>Sign Up </title>
<BODY>
<table cellspacing='0' cellpadding='5' width='100%' height='100%' bgcolor='#FFFFFF' nosave border='0' style='border: 1px solid rgb(128,255,128)'>
<tr>

<td valign='top'>
<center>
The following information will be submitted to the administrator of
the WishList Site who will create an account for you.  You will
receive an email with your WishList password when the account is
created.


<p> 
<form method=post action='registerUser.php?m=1'>
<table style='border-collapse: collapse;' id='AutoNumber1' border='0' bordercolor='#111111' cellpadding='2' cellspacing='0' bgcolor=lightYellow>

<tr><td colspan='2' align='center' bgcolor='#6702cc'>
<font size=3 color=white><b>Please Fill In</b></font>
</td></tr>
<tr>
<td align=right><b>First Name</b></td>
<td><input type=text name=fname size=20></td>
</tr>
<tr>
<td align=right><b>Last Name</b></td>
<td><input type=text name=lname size=20></td>
</tr>
<tr>
<td align=right><b>Suffix</b></td>
<td><input type=text name=suffix size=20></td>
</tr>
<tr>
<td align=right><b>Desired Userid</b></td>
<td><input type=text name=userid size=20></td>
</tr>

<tr>
<td align=right><b>Email</b></td>
<td><input type=text name=email size=40></td>
</tr>

<tr>
<td align=right><b>Comment</b></td>
<td><textarea name=comment rows=3 cols=60></textarea></td>
</tr>

<tr><td align='center' colspan='2' bgcolor='#c0c0c0'>
<input type='submit' value='Submit' style='font-weight:bold'>

</td></tr>
</table>

</form>

</center>
</td>
</tr>
</table>
</body>
</html>";







}



?>

Link to comment
Share on other sites

this one works, but there is no validation so if you submit form without any values it still runs the query and inserts values and sends email.

 

 

it is working i have it hosted here

http://phedx.azsurveillance.net/scripts_trials/freaks/registerUser.php

 

there is two html tags because the 2nd html is the main form after the form is submitted the form submit and goes to the following url

http://phedx.azsurveillance.net/scripts_trials/freaks/registerUser.php?m=1

if you see the script it says if the message = 1 it will echo thank you you have succesfully registered if not it will echo the main form this is why it has two html tags

 

Link to comment
Share on other sites

well the script  that i uploaded doesn't actually create the database it just refers to it you have to create the database yourself. Did you already do this my databse is composed of the following.

 



CREATE TABLE IF NOT EXISTS `people` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `email` varchar(200) NOT NULL,
  `admin` int(1) NOT NULL,
  `fname` varchar(300) NOT NULL,
  `lname` varchar(300) NOT NULL,
  `suffix` varchar(50) NOT NULL,
  `userid` varchar(100) NOT NULL,
  `comment` varchar(500) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

 

http://phedx.azsurveillance.net/scripts_trials/freaks/people.sql

 

you can download it here

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.