Registration form works randomly...hmmmmm

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
odie2828
Forum Commoner
Posts: 39
Joined: Tue Aug 05, 2008 4:40 pm

Registration form works randomly...hmmmmm

Post by odie2828 »

Ok i have this code that is supposed to take the information that is entered into the form and then insert it into a database and also email it to the client.

The script works whenever it wants... sometimes it will work 5 times in a row and then some times itwont work at all or just once in a while...

I am fairly new to this kind of programming and wondering if someone could critique my work.

Please let me know what there is that i can do.

Thank you in advance!


[code=text
<?php            
 
if(!isset($_REQUEST['relation1'])) {
  $_REQUEST['relation1'] = 'Self';
}
if(!isset($_REQUEST['health'])) {
  $_REQUEST['health'] = 'Thyroid';
}
if(!isset($_REQUEST['gender1'])) {
  $_REQUEST['gender1'] = 'Female';
}
if(!isset($_REQUEST['prescription1'])) {
  $_REQUEST['prescription1'] = 'Yes';
}
 
$to="jd@creativpowers.com";
$contact_us_text="Contact us form.";
$sent_message="<b>Thank you for registering with AssuredRx.com.</b><br />";
$sent_message .="Please wait to be redirected to the Log In Page.";
$small_text="(Please complete the form then press submit)";
$contact_page="new_pat_reg_1.php";
$subject="${_POST['mname']} filled out the New Patient Registration Page";
$from="info@assuredrx.com, Assured Rx - Contact Page";
$headers="From: $from";
 
 
if(isset($_POST['submit']))
 {
 
 
 
 
$dbhost="localhost";
 
$dbusername="assuredr_checklo";
 
$dbpassword="check";
 
$dbname="assuredr_members";
 
$connect = mysql_connect($dbhost, $dbusername, $dbpassword);
 
mysql_select_db($dbname,$connect) or die ("Could not select database");
 
 
 
      $mname = mysql_escape_string($_POST['mname']);
      $healthprovide = mysql_escape_string($_POST['healthprovide']);
      $amin = mysql_escape_string($_POST['amin']);
      $address = mysql_escape_string($_POST['address']);
      $city = mysql_escape_string($_POST['city']);
      $state = mysql_escape_string($_POST['state']);
      $zip = mysql_escape_string($_POST['zip']);
      $email = mysql_escape_string($_POST['email']);
      $dphone1 = mysql_escape_string($_POST['dphone1']);
      $dphone2 = mysql_escape_string($_POST['dphone2']);
      $dphone3 = mysql_escape_string($_POST['dphone3']);
      $ephone1 = mysql_escape_string($_POST['ephone1']);
      $ephone2 = mysql_escape_string($_POST['ephone2']);
      $ephone3 = mysql_escape_string($_POST['ephone3']);
      $docname = mysql_escape_string($_POST['docname']);
      $docnumber1 = mysql_escape_string($_POST['docnumber1']);
      $docnumber2 = mysql_escape_string($_POST['docnumber2']);
      $docnumber3 = mysql_escape_string($_POST['docnumber3']);
      $username = mysql_escape_string($_POST['username']);
      $password = mysql_escape_string($_POST['password']);
      $passconf = mysql_escape_string($_POST['passconf']);
      $birth1 = mysql_escape_string($_POST['birth1']);
           
 
 
     if ($password != $passconf) {
 
  echo "Passwords do not match</p>";
  echo "<P><a href=\"#\" onClick=\"history.go(-1)\">Try Again.</a></p>";
  exit;
  }  
 
 $sql ="SELECT * FROM patients WHERE username= '$_POST[username]'";
$res = @mysql_query($sql,$connect) or die(mysql_error());
 
//get the number of rows in the result set
$num = mysql_num_rows($res);
 
 
 
   $result = mysql_query("INSERT INTO patients (amin, mname, username, password, email, healthprovide, address, city, state, zip, dphone1, dphone2, dphone3, ephone1, ephone2, ephone3, docname, docnumber1, docnumber2, docnumber3, birth)
 
                       VALUES ('$amin', '$mname', '$username', '$password', '$email', '$healthprovide', '$address', '$city', '$state', '$zip', '$dphone1', '$dphone1', '$dphone2', '$ephone1', '$ephone2', '$ephone3', '$docname', '$docnumber1', '$docnumber2', '$docnumber3', '$birth1')",$connect);
 
 
        $msg .="\n";
        $msg .="***Member Account Information***\n";
        $msg .="\n";
        $msg .="Member Name:\n";
        $msg .="  ${_POST['mname']}\n";
        $msg .="\n";
        $msg .="Healthcare Provider:\n";
        $msg .="  ${_POST['healthprovide']}\n";
        $msg .="\n";
        $msg .="E-mail:\n";
        $msg .="  ${_POST['email']}\n";
        $msg .="\n";
        $msg .="Date of Birth:\n";
        $msg .="  ${_POST['birth1']}\n";
        $msg .="\n";
        $msg .="Member Identification Number:\n";
        $msg .="  ${_POST['amin']}\n";
        $msg .="\n";
        $msg .="Daytime Phone:\n";
        $msg .="  (${_POST['dphone1']}) ${_POST['dphone2']}-${_POST['dphone3']}\n";
        $msg .="\n";
        $msg .="Evening Phone:\n";
        $msg .="  (${_POST['ephone1']}) ${_POST['ephone2']}-${_POST['ephone3']}\n";
        $msg .="\n";
        $msg .="Address:\n";
        $msg .="  ${_POST['address']}\n";
        $msg .="  ${_POST['city']},${_POST['state']}\n";
        $msg .="  ${_POST['zip']}\n";
        $msg .="\n";
        $msg .="Gender:\n";
        $msg .="  ${_POST['gender1']}\n";
        $msg .="\n";
        $msg .="Date of Birth:\n";
        $msg .="  ${_POST['birth1']}\n";
        $msg .="\n";
        $msg .="\n";
        $msg .="***Patient Information***\n";
        $msg .="\n";
        $msg .="\n";
        $msg .="Doctor Name and Number:\n";
        $msg .="  ${_POST['docname']}\n";
        $msg .="  (${_POST['docnumber1']}) ${_POST['docnumber2']}-${_POST['docnumber3']}\n";
        $msg .="\n";
        $msg .="Other prescription Coverage:\n";
        $msg .="  ${_POST['prescription1']}\n";
        $msg .="\n";
        $msg .="Allergies:\n";
        if(isset($_POST['allergies1'])) {
            $msg .="  ${_POST['allergies1']}\n";
        }
        if(isset($_POST['allergies2'])) {
            $msg .="  ${_POST['allergies2']}\n";
        }
        if(isset($_POST['allergies3'])) {
            $msg .="  ${_POST['allergies3']}\n";
        }
        if(isset($_POST['allergies4'])) {
            $msg .="  ${_POST['allergies4']}\n";
        }
        if(isset($_POST['allergies4'])) {
            $msg .="\n";
            $msg .="Other Allergies:\n";
            $msg .="  ${_POST['allergy_other']}\n";
        }          
        $msg .="\n";
        $msg .="Health Conditions:\n";
        if(isset($_POST['health1'])) {
            $msg .="  ${_POST['health1']}\n";
        }
        if(isset($_POST['health2'])) {
            $msg .="  ${_POST['health2']}\n";
        }
        if(isset($_POST['health3'])) {
            $msg .="  ${_POST['health3']}\n";
        }
        if(isset($_POST['health4'])) {
            $msg .="  ${_POST['health4']}\n";
        }
        if(isset($_POST['health5'])) {
            $msg .="  ${_POST['health5']}\n";
        }
        if(isset($_POST['health_other'])) {
            $msg .="\n";
            $msg .="Other Health Conditions:\n";
            $msg .="  ${_POST['health_other']}\n";
        }
        $msg .="\n";
        mail( $to, $subject, $msg, $headers);
        echo '<table border= "0" cellpadding = "0" cellspacing="0" width="500"><tr><td><div align=center><table align=center><tr><td height=280>';     
        echo '<p class="sent_message">'.$sent_message.'</p></td></tr></table></div></td></tr></table>';
        echo "<meta http-equiv=Refresh content=5;url=http://www.assuredrx.com/members/patien ... _login.php>";
        }
    else
        {
 
        ?>
</td>
 
            <td width="25" height="15">&nbsp;</td>
 
          </tr>
 
          <tr>
 
            <td width="25" height="1033">&nbsp;</td>
 
            <td width="500" align="center"><p align="left" class="style9">Please complete the following form, including the patient profile on the reverse side, and return it to Assured
 
              Rx in the enclosed pre-addressed envelope. Be sure to sign the form and enclose the original prescriptions
 
              along with your check, money order, or credit card information.
 
               
 
            </p>
              <p align="left" class="style5">Member Account Information<br />
                <span class="style8">(Please complete the form below)</span></p>
              <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF ?>">
 
// --------FORM IS HERE--------\\



                </form>              </td>
<?
      }
           ?>
             
Last edited by odie2828 on Thu Nov 06, 2008 6:30 pm, edited 1 time in total.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Registration form works randomly...hmmmmm

Post by aceconcepts »

You know you posted 1018 lines of code!!!

Thats quite a lot to read through - rethink your approach...try posting the most relevant code :wink:
Post Reply