Jump to content

[SOLVED] Registration Script Problems


interpim

Recommended Posts

I created a registration script, and had it working fine... I wanted to add a email verification to this, basically creating a random code, emailing it, and having the user input this random code before the account could be validated...

 

Well, now the script outputs nothing :( 

 

I've checked the random script code, and it works here is a link of just the random code generator function in action  http://interpim.com/ambassade/testfunction.php

 

the registration code is

 

<?php
include('config.php');
include('includes/functions.php');

$user=$_POST['username'];
$pword=$_POST['password'];
$pword2=$_POST['password2'];
$email=$_POST['email'];

if (empty($user) || empty($pword) || empty($email))
{
header("Location: register.php?err=1");
exit();
}

mysql_connect($server,$username,$password);
@mysql_select_db($database) or die("unable to select database");
$query="SELECT * FROM main WHERE user_name='$user'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();


if ($num!=0)
  {
  echo "That username has already been taken, please try again<br>
  <a href='register.php'>Register</a>";
  }
elseif ($pword!=$pword2)
  {
  echo "The supplied passwords you gave do not match<br><a href='register.php'>Try Again</a><br>";
   exit();
  }

mysql_connect($server,$username,$password);
@mysql_select_db($database) or die("unable to select database");
$af=0;
$query = "INSERT INTO main VALUES('','$user','$pword','','','','','','','','','','','','$af','','$code','','','','','','','$email','','','')";
mysql_query($query);
mysql_close();

                setcookie("user","$user");
                setcookie("loggedin","true",time()+(86400*5));

  $code=code_gen();
  $reg_sub="Ambassade Game Registration confirmation email";
  $reg_body="Thank you for registering for Ambassade... before you can log in, you must confirm your email by entering the following code on our website./n/n/n/n$code/n/n/n/n Thank you again,/n/nTeam Ambassade.";
  mail($email,$reg_sub,$reg_body);
  echo "Thank you for registering... you will shortly receive an email with a confirmation code<br>";
  echo "<a href="members.php">Go there now</a></br>";
  


?>

 

anyone help me figure otu what I did wrong?

Link to comment
Share on other sites

Here is my changed code... still outputting a blank page.

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include('config.php');
include('includes/functions.php');

$user=$_POST['username'];
$pword=$_POST['password'];
$pword2=$_POST['password2'];
$email=$_POST['email'];

if (empty($user) || empty($pword) || empty($email))
{
header("Location: register.php?err=1");
exit();
}

mysql_connect($server,$username,$password);
mysql_select_db($database) or die("unable to select database");
$query="SELECT * FROM main WHERE user_name='$user'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();


if ($num!=0)
  {
  echo "That username has already been taken, please try again<br>
  <a href='register.php'>Register</a>";
  exit();
  }
elseif ($pword!=$pword2)
  {
  echo "The supplied passwords you gave do not match<br><a href='register.php'>Try Again</a><br>";
   exit();
  }

mysql_connect($server,$username,$password);
mysql_select_db($database) or die("unable to select database");
$af=0;
$query = "INSERT INTO main VALUES('','$user','$pword','','','','','','','','','','','','$af','','$code','','','','','','','$email','','','')";
mysql_query($query);
mysql_close();

                setcookie("user","$user");
                setcookie("loggedin","true",time()+(86400*5));

  $code=code_gen();
  $reg_sub="Ambassade Game Registration confirmation email";
  $reg_body="Thank you for registering for Ambassade... before you can log in, you must confirm your email by entering the following code on our website./n/n/n/n $code /n/n/n/n Thank you again, /n/n Team Ambassade.";
  mail($email,$reg_sub,$reg_body);
  echo "Thank you for registering... you will shortly receive an email with a confirmation code<br>";
  echo "<a href="members.php">Go there now</a></br>";
  


?>

Link to comment
Share on other sites

OK... i atleast fixed that first problem, i had double quotes in an echo statement instead of single quotes and it was killing the entire script...  It is giving me an error now, saying that there is an undefined variable on line 41... which is $af=0;

 

One more quick question... how would I echo new lines in an email body... the /n's I put into the body actually displayed in the email.

Link to comment
Share on other sites

In your code, just press enter and go to the next line, it will do the same when the email sends out. For example:

 

 

$body = "this is my body message


and this line is down a few";

 

Doing that should cause space in the email, that has worked for me in the past anyway, so give that a shot and see if you get what you wanted out of it.

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.