FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need help with PHP script[RESOLVED]





rfwrangler
I am working on a script that will allow users to update their profile information. I am not finding where the script is hanging up an help would be greatly appreciated. Here is the script that I am having trouble with:
Code:
<?php
//Assign $_POST[variables] to simple variables that can be used in PHP
$password_new = $_POST['password_new'];
$password_new2 = $_POST['password_new2'];
$password_old = $_POST['password_old'];
$sex = $_POST['sex'];
$address_1 = $_POST['address_1'];
$address_2 = $_POST['address_2'];
$city = $_POST['city'];
$state_prov = $_POST['state_prov'];
$country = $_POST['country'];
$zipcode = $_POST['zipcode'];
$user_info = $_POST['user_info'];
$tm_club = $_POST['tm_club'];
$tm_club_num = $_POST['tm_club_num'];
$club_info = $_POST['club_info'];
$newsletter = $_POST['newsletter'];
$picture_file = $_POST['picture_file'];
//stripslashes from variables.
$password_new = stripslashes($password_new);
$password_new2 = stripslashes($password_new2);
$password_old = stripslashes($password_old);
$sex = stripslashes($sex);
$address_1 = stripslashes($address_1);
$address_2 = stripslashes($address_2);
$city = stripslashes($city);
$state_prov = stripslashes($state_prov);
$country = stripslashes($country);
$zipcode = stripslashes($zipcode);
$user_info = stripslashes($user_info);
$tm_club = stripslashes($tm_club);
$tm_club_num = stripslashes($tm_club_num);
$club_info = stripslashes($club_info);
$newsletter = stripslashes($newsletter);
$picture_file = stripslashes($picture_file);
//process data from variables
//error checking of password change
//Check if all fields are provided.
if (isset($password_new) {
   if((!$password_new2) || (!$password_old)) {
      echo "You forgot to fill in a value in order to change your password!<br />\n";
      if(!$password_old) {
         echo "Please fill in your old password.<br />\n";
      }
      if(!$password_new2) {
         echo "Please fill in the new password again.<br />\n";
      }
      include 'Resources/PHPModules/profile_update.php';
      include 'Resources/HTML/error_include_registration.html';
      exit()
      };
   if($password_new != $password_new2) {
      echo "Both enteries of the new password must match!<br />\n";
         include 'Resources/PHPModules/profile_update.php';
         include 'Resources/HTML/error_include_registration.php';
   exit()
   };
   $sql_check = mysql_query
   ("SELECT * FROM members WHERE member_name='$member_name' AND password='$password_old'");
   $sql_check_num = mysql_num_rows($sql_check);
      if($sql_check_num == 0) {
         echo "Your Username and Old Password did not match in our database.&nbsp;&nbsp;Please, try
         again.<br />\n";
            include 'Resources/PHPModules/profile_update.php';
            include 'Resources/HTML/error_include_registration.html';
      exit();
      }
//If the above checks out then encrypt the password and enter it into the database
      $db_password=md5($password_new);
   $sql_password = mysql_query
      ("UPDATE members SET password='$db_password' WHERE member_name='$member_name'");
}
//Set new values to database.
/*echo "<table align=\"center\">\n
      <tr>\n
         <td colspan=\"2\" class\"alert\" alignment=\"justify\">Your profile has been updated in our
         database:(items in red have been changed)</td>\n
      </tr>\n
      <tr>\n
         <td align=\"left\">First Name:</td>\n
         <td align=\"left\">$first_name</td>\n
      <\tr>\n
      <tr>\n
         <td align=\"left\">Last Name:</td>\n
         <td align=\"left\">$last_name</td>\n
      </tr>\n
      <tr>
         <td align=\"left\">Username:</td>\n
         <td align=\"left\">$member_name</td>\n
      </tr>\n";
if(isset($password)) {
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">PASSWORD:</td>\n
         <td class=\"alert\" align=\"left\">Your new password was sent to your Email Address for
         security reasons</td>
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Password:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
   }                
if(isset($sex)) {
   $sql_sex = mysql_query
      ("UPDATE members SET sex='$sex' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">SEX:</td>\n
         <td class=\"alert\" align=\"left\">$sex</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Sex:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";         
   }
   echo "<tr>\n
         <td align=\"left\">Email Address:</td>\n
         <td align=\"left\">$email_address</td>\n
      </tr>\n";
if(isset($address_1)) {
   $sql_address_1 = mysql_query
      ("UPDATE members SET address_1='$address_1' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">ADDRESS 1:</td>\n
         <td class=\"alert\" align=\"left\">$address_1</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Address 1:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($address_2)) {
   $sql_address_2 = mysql_query
      ("UPDATE members SET address_2='$address_2' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">ADDRESS 2:</td>\n
         <td class=\"alert\" align=\"left\">$address_2</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Address 2:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($city)) {
   $sql_city = mysql_query
      ("UPDATE members SET city='$city' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">CITY:</td>\n
         <td class=\"alert\" align=\"left\">$city</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">City:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($state_prov)) {
   $sql_state_prov = mysql_query
      ("UPDATE members SET state_prov='$state_prov' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">STATE/PROVIDENCE:</td>\n
         <td class=\"alert\" align=\"left\">$state_prov</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">State/Providence:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($country)) {
   $sql_country = mysql_query
      ("UPDATE members SET country='$country' WHERE member_name='$member_name'");
      echo "<tr>\n
         <td class=\"alert\" align=\"left\">COUNTRY:</td>\n
         <td class=\"alert\" align=\"left\">$country</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Country:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($zipcode)) {
   $sql_zipcode = mysql_query
      ("UPDATE members SET zipcode='$zipcode' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">ZIP CODE:</td>\n
         <td class=\"alert\" align=\"left\">$zipcode</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Zip Code:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($user_info)) {
   $user_info2 = htmlspecialchars($user_info);
   $sql_user_info = mysql_query
      ("UPDATE members SET user_info='$user_info2' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">USER INFORMATION:</td>\n
         <td class=\"alert\" align=\"left\">$user_info</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">User Information:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($tm_club)) {
   $sql_tm_club = mysql_query
      ("UPDATE members SET tm_club='$tm_club' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">TOASTMASTERS CLUB:</td>\n
         <td class=\"alert\" align=\"left\">$tm_club</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Toastmasters Club:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($tm_club_num)) {
   $sql_tm_club_num = mysql_query
      ("UPDATE members SET tm_club_num='$tm_club_num' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">CLUB NUMBER:</td>\n
         <td class=\"alert\" align=\"left\">$tm_club_num</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Club Number:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($club_info)) {
   $club_info2 = htmlspecialchars($club_info);
   $sql_club_info = mysql_query
      ("UPDATE members SET club_info='$club_info2' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">CLUB INFORMATION:</td>\n
         <td class=\"alert\" align=\"left\">$club_info</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Club Information:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($newsletter)) {
   $sql_newsletter = mysql_query
      ("UPDATE members SET newsletter='$newsletter' WHERE member_name='$member_name'");
   echo "<tr>\n
         <td class=\"alert\" align=\"left\">NEWSLETTER:</td>\n
         <td class=\"alert\" align=\"left\">$newsletter</td>\n
      </tr>\n";
   } else {
      echo "<tr>\n
            <td align=\"left\">Newsletter:</td>\n
            <td align=\"left\" class=\"required\">WAS NOT CHANGED</td>\n
         </tr>\n";
}
if(isset($password)) {
$subject = "Password change on the Eureka Toastmasters Club website";
$message = "Hello, you have recently updated your password.  Here is your new login information:

   Your Username is: $member_name
   Your new password is: $password

You may use this password to login at http://www.rfwrangler.frih.net.


Thank you,
The Webmaster
The Eureka Toastmasters Club

This is an automated response, please DO NOT reply!";
   mail
($email_address, $subject, $message, "From: The Eureka Toastmasters Club Webmaster<noreply@rfwrangler.frih.net>
   n X-Mailer: PHP/" . phpversion());
   echo "<tr>\n
         <td colspan=\"2\" class=\"alert\" align=\"justify\">Your Username and NEW Password have been
         sent to your Email Address.&nbsp;&nbsp;Please check your email.</td>\n
      </tr>\n";
}
echo "</table>\n";*/
include 'Resources/HTML/error_include_registration.html';      
?>
hexkid
rfwrangler wrote:
I am working on a script that will allow users to update their profile information. I am not finding where the script is hanging up an help would be greatly appreciated. Here is the script that I am having trouble with


You're missing these first two lines after <?php
Code:
<?php
error_reporting(E_ALL);         ### first line missing
ini_set('display_errors', '1'); ### second line missing

//Assign $_POST[variables] to simple variables that can be used in PHP
$password_new = $_POST['password_new'];
// ...
rfwrangler
Thank you for the two lines of code to help with the debugging I had some typos in the code.
Related topics
[Help] php script to post to twitter
Please help. php script installation error
Uploading an Image using PHP script - RESOLVED
error in my PHP script
Needing a Bit Og Help {PHP}!
Help with upload form script! [RESOLVED]
array check box on php script using $_POST
php script not loading
need php script to test if domain is Blacklisted
Run a php Script with a Cron Job
Need php script
Phoenix free PHP scripts
how can i make a php script for enter username and password?
Inserting data to MYSQL with a PHP script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.