Jump to content

[SOLVED] Having Problems Registering.


Trium918

Recommended Posts

Problem:When I submit the form I am getting a blank page.

The first calls the function register(). The second script is

the function.

<?php
   // include function files for this application
   require_once("container_fns.php");

   // start session which may be needed later
   // start it now because it must go before headers
   session_start();
   
   // check forms filled in
   if (!filled_out($_POST)) // (!filled_out($HTTP_POST_VARS))
   {
      do_html_header("Problem:");
      echo "You have not filled the form out correctly - please go back"
           ." and try again.";
      do_html_footer();
      exit; 
   }    

   // email address not valid
   if (!valid_email($email_address))
   {
      do_html_header("Problem:");
      echo "That is not a valid email address.  Please go back "
           ." and try again.";
      do_html_footer();
      exit;
   } 

   // passwords not the same 
   if ($password != $cpassword)
   {
      do_html_heading("Problem:");
      echo "The passwords you entered do not match - please go back"
           ." and try again.";
      do_html_footer();
      exit;
   }

   // check password length is ok
   // ok if username truncates, but passwords will get
   // munged if they are too long.
   if (strlen($password)<6 || strlen($cpassword) >25)
   {
      do_html_header("Problem:");
      echo "Your password must be between 6 and 25 characters."
           ."Please go back and try again.";
      do_html_footer();
      exit;
   }
   // attempt to register
   $reg_result = register($member_id,$user_name,$first_name,$last_name,$gender,$birth_month,$birth_day,
   $birth_year,$contact_number,$email_address, Now());
   if ($reg_result == "true")
   {
     // register session variable 
     $valid_user = $user_name;
     $_SESSION['valid_user'] = $valid_user; // instead of session_register("valid_user");

     // provide link to members page
     do_html_header("Registration successful");
     echo "Your registration was successful.  Go to the members page "
          ."to start setting up your bookmarks!";
     do_HTML_URL("member.php", "Go to members page");
   }
   else
   {
     // otherwise provide link back, tell them to try again
     do_html_header("Problem:");
     echo $reg_result; 
     do_html_footer();
     exit;
   }

   // end page
   do_html_footer();
     
?>

 

The function!!

<?php

require_once("db_fns.php");

function register($members_id,$user_name,$first_name,$last_name,$gender,$birth_month,$birth_day,
   $birth_year,$contact_number,$email_address,$register_date)
// register new person with db
// return true or error message
{
// connect to db
  $conn = db_connect();
  if (!$conn)
    return "Could not connect to database server - please try later.";

  // check if username is unique 
  $result = mysql_query("select * from user where user_name='$user_name'"); 
  if (!$result)
     return "Could not execute query";
  if (mysql_num_rows($result)>0) 
     return "That username is taken - go back and choose another one.";

  // if ok, put in db
  $result = mysql_query("INSERT INTO members_info (members_id,user_name,first_name,last_name,gender,birth_month,birth_day,
birth_year,contact_number,email_address,register_date) VALUES(NULL,'$user_name','$first_name','$last_name'
,'$gender','$birth_month','$birth_day','$birth_year','$contact_number','$email_address',Now())");

  if (!$result)
    return "Could not register you  in database - please try again later.";

  return true;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/47667-solved-having-problems-registering/
Share on other sites

For starters.

 

if ($reg_result == "true")

 

Should be...

 

if ($reg_result)

 

Its pretty difficult to see whats actually happening. Are you sure that your do_html_error works? Because we cant see it, your code is pretty hard to debug.

 

do_html_header is just functions

<?php
<?
function do_html_header($title)
{
  // print an HTML header
?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <title><?=$title?></title>
  <link href ="Style/Style_sup.css" rel ="stylesheet" type ="text/css" media = "screen" />
  <script type='text/javascript' language='javascript' src='./Jscripts/superiun_scripts.js'></script>
  </head>
  <body>
    <table width="760" border="0" cellspacing="0" cellpadding="7" class="bodyline" align="center">
  	<tr>
      <td colspan="2" height="120"><img src="images/cellpic4.gif" width="760" height="120" /></td>
    </tr>
    <tr><td colspan="2" class ="topnav" > 
  			<ul>
			<li><a href="demo.html ">Home</a></li>
			<li><a href="">News</a></li>
			<li><a href="how_it_works.html">About Us</a></li>
			<li><a href="login.html">Login</a></li>
			<li><a href="">Forum</a></li>	
			<li><a href="">FAQ</a></li>
		</ul>
    </td></tr>
    <tr>
      <td width="530" height="150" valign="top">


<?

?>

Archived

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

×
×
  • 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.