Jump to content

Recommended Posts

see i have a register form and the only pages are the functions.php and the register.php. everytime i attempt to sign up the page will just go blank what is the problem here?

 

 

<?php

include_once "functions.php";

 

connect();

 

if(!$_POST['submit']){

echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";

echo "<form method=\"post\" action=\"register.php\">\n";

echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";

echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n";

echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n";

echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n";

echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n";

echo "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";

echo "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td></tr>\n";   

        echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n";

        echo "</form></table>\n"; 

}else {

    $username = protect($_POST['username']);

    $password = protect($_POST['password']);

    $confirm = protect($_POST['passconf']);

    $email = protect($_POST['email']);

    $name = protect($_POST['name']);

    $aim = protect($_POST['aim']); 

 

    $errors = array();

   

        if (!$username) {

        $errors[] = "Username is not defined!";

}

 

if($password){

  $errors[] = "Password is not defined!";

        }

 

        if($password){

        if(!$confirm){

$errors[] = "Confirmation password is not defined!";

        }

        }

 

        if(!$email){

$errors[] = "Email is not defined!"; 

}

     

        if(!$name){

            $errors[] = "Name is not defined!";

        }

       

        If (!$aim){

$errors[] = "AIM Screename is not defined!";

        }

 

if ($username) {

if(!ctype_alnum($username)){

$errors[] = "Username can only contain numbers and letters!";

}

}

 

        if($password && $confirm) {

 

}   

}

 

     

?>   

 

 

 

 

 

functions.php

<?php

 

function protect($string){

    $string = mysql_real_escape_string($string);

    $string = strip_tags($string);

    $string = addslashes($string);

   

    return $string;

}   

 

function connect () {

    $con = mysql_connect( 'localhost', 'MYNAME', 'MYPASSWORD') or die(mysql_error());

    $db = mysql_select_db( 'MYNAME_users', $con);

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/95889-solved-php-register-to-blank-page/
Share on other sites

try

<?php
error_reporting(E_ALL);
include_once "functions.php";

connect();

if(!isset($_POST['submit'])){
   echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
   echo "<form method=\"post\" action=\"register.php\">\n";
   echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";
   echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n";
   echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n";
   echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n";
   echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n";
   echo "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";
   echo "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td></tr>\n";   
        echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n";
        echo "</form></table>\n"; 
}
else {
    $username = protect($_POST['username']);
    $password = protect($_POST['password']);
    $confirm = protect($_POST['passconf']);
    $email = protect($_POST['email']);
    $name = protect($_POST['name']);
    $aim = protect($_POST['aim']); 
   
    $errors = array();
   
        if (!$username) {
            $errors[] = "Username is not defined!";
      }   
      
      if($password){
         $errors[] = "Password is not defined!";
        }

        if($password){
           if(!$confirm){
            $errors[] = "Confirmation password is not defined!";
           }
        }

        if(!$email){
         $errors[] = "Email is not defined!";   
      }
     
        if(!$name){
            $errors[] = "Name is not defined!";
        }
         
        If (!$aim){
          $errors[] = "AIM Screename is not defined!";
           }
      
      if ($username) {
          if(!ctype_alnum($username)){
          $errors[] = "Username can only contain numbers and letters!";
          }
      }

        if($password && $confirm) {

}     
}

       
?>     

Because you haven't given it anything to show:

 

<?php
error_reporting(E_ALL);
include_once "functions.php";

connect();

if(!isset($_POST['submit'])){
   echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
   echo "<form method=\"post\" action=\"register.php\">\n";
   echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";
   echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n";
   echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n";
   echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n";
   echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n";
   echo "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";
   echo "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td></tr>\n";   
        echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n";
        echo "</form></table>\n"; 
}
else {
    $username = protect($_POST['username']);
    $password = protect($_POST['password']);
    $confirm = protect($_POST['passconf']);
    $email = protect($_POST['email']);
    $name = protect($_POST['name']);
    $aim = protect($_POST['aim']); 
   
    $errors = array();
   
        if (!$username) {
            $errors[] = "Username is not defined!";
      }   
      
      if($password){
         $errors[] = "Password is not defined!";
        }

        if($password){
           if(!$confirm){
            $errors[] = "Confirmation password is not defined!";
           }
        }

        if(!$email){
         $errors[] = "Email is not defined!";   
      }
     
        if(!$name){
            $errors[] = "Name is not defined!";
        }
         
        If (!$aim){
          $errors[] = "AIM Screename is not defined!";
           }
      
      if ($username) {
          if(!ctype_alnum($username)){
          $errors[] = "Username can only contain numbers and letters!";
          }
      }

        if($password && $confirm) {
echo "IT WORKS!";
}     
}

       
?> 

I think thats were it goes...

Try and see if there is something wrong with mysql:

functions.php

<?php

function protect($string){
    $string = mysql_real_escape_string($string);
    $string = strip_tags($string);
    $string = addslashes($string);
   
    return $string;
}   

function connect () {
    $con = mysql_connect( 'localhost', 'MYNAME', 'MYPASSWORD') or die(mysql_error());
    $db = mysql_select_db( 'MYNAME_users', $con) or die(mysql_error());
}

?>

This is starting to get weird... Sorry I couldn't help.

----

Do you use cpanel? If so I THINK I see the error.

yea i went to control panel on my web hoster and there server host is local host and i had named my db

 

"WITHMYNAME_users" thats what i put for the select statement in functions just to let you know and the name has to go before the name u choose. i just dont see where i can connect the form to the db table so it knows where to store it because as you know my codes suck a bit

Well if your using a shared database with other people, you have to use:

    $con = mysql_connect( 'localhost', 'MYNAME_username', 'MYPASSWORD') or die(mysql_error());
    $db = mysql_select_db( 'MYNAME_dbname', $con) or die(mysql_error());

 

And you have to created the dbname and username and add permissions to them.

can you tell us your real problem now?

 

what do you mean?

 

 

and derrick i have all the info down, i think my problem is not a way to give the page a place to send the info via table. what am i missing because i clearly havent put the table name down there just not sure how to go about that

you need something like

 

// create query
$query = "INSERT INTO table (field, field, etc) VALUES ($value, $value, etc)";

// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

 

After all checks are done.

 

omg thats what i forgot the insert query not exactly this but the insert into 'users' etc.

im getting a new error when i sign up i got all the things i needed now i get this

 

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Admin','0b91dec4fe98266a03b136b59219d0d6','testemail1@yahoo.com','Testname','te' at line 3

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.