...

View Full Version : my php script is not working and wont post errors



poysyn
01-13-2010, 08:20 AM
Ok, so here is my user interface script




<?php

$employee_query = mysql_query("SELECT * FROM `accounts` WHERE NOT `name` = '$username' ORDER BY `last` ASC");
$i = 0;
echo '<div align="center"><div class="title">Edit Employee Accounts</div><br /></div>
<form method="post" action="employee.php?page=edit_employees">
<div align="center">';
?>
<select name="selected" class="my-select">
<?php

while($employee_data = mysql_fetch_array($employee_query)){
$rNames = $employee_data['name'];
$last = $employee_data['last'];
$first = $employee_data['first'];

$i++;
?>
<option value="<?php echo $rNames; ?>"<?php if($i <= 1) { echo ' selected'; } ?>><?php echo $last . ', ' . $first; ?></option>
<?php
}
?>
</select>
<?php
echo '<input type="submit" name="get_info" value="Get Info" /></div>';

if(isset($_POST['get_info'])){

$names = trim($_POST['selected']);
$adm_data = mysql_num_rows(mysql_query("SELECT * FROM admins WHERE username = '$names'"));
$acc_data = mysql_fetch_array(mysql_query("SELECT * FROM accounts WHERE name = '$names'"));
$name = $acc_data['name'];
$admin = $acc_data['admin'];
$manager = $acc_data['manager'];
$first = $acc_data['first'];
$last = $acc_data['last'];
$email = $acc_data['email'];
$password = $acc_data['password'];
$current_acode = $acc_data['acode'];
$current_first3 = $acc_data['first3'];
$current_last4 = $acc_data['last4'];
$current_carrier = $acc_data['carrier'];
$current_text = $acc_data['text'];
$current_altacode = $acc_data['altacode'];
$current_altfirst3 = $acc_data['altfirst3'];
$current_altlast4 = $acc_data['altlast4'];
$current_altcarrier = $acc_data['altcarrier'];
$current_alttext = $acc_data['alttext'];

?>
<table align="center">
<tr>
<td align="center" valign="center">Choose new account status:</td>
<td><input type="radio" name="choice" value="user"<?php if (($admin == '0') and ($manager == '0')) { echo ' checked="yes"'; } ?>>User<br>
<input type="radio" name="choice" value="manager"<?php if (($admin == '0') and ($manager == '1')) { echo ' checked="yes"'; } ?>>Manager<br>
<input type="radio" name="choice" value="admin"<?php if (($admin == '1') and ($manager == '1')) { echo ' checked="yes"'; } ?>>Administrator<br>
<input type="checkbox" name="schedman" value="yes"><small>Make/Remove Schedule Editor</small><br /><br />
<b><u>Change Phone Number</u></b><br /><input type="text" name="phonechange1" value="<?php echo $current_acode; ?>" size="1" maxlength="3"><b>-</b><input type="text" name="phonechange2" value="<?php echo $current_first3; ?>" size="1" maxlength="3"><b>-</b><input type="text" name="phonechange3" value="<?php echo $current_last4; ?>" size="2" maxlength="4"><br>
<b><u>Change Service Carrier</u></b>
<select name="carrier" class="my-select">
<option value="Not A Cell Phone"<?php if($current_carrier == 'Not A Cell Phone') { echo ' selected'; } ?>>Not A Cell Phone</option>
<option value="Not Listed"<?php if($current_carrier == 'Not Listed') { echo ' selected'; } ?>>Not Listed</option>
<option value="Alltel"<?php if($current_carrier == 'Alltel') { echo ' selected'; } ?>>Alltel</option>
<option value="ATT"<?php if($current_carrier == 'ATT') { echo ' selected'; } ?>>AT&amp;T</option>
<option value="Boost"<?php if($current_carrier == 'Boost') { echo ' selected'; } ?>>Boost Mobile</option>
<option value="Helio"<?php if($current_carrier == 'Helio') { echo ' selected'; } ?>>Helio</option>
<option value="Metro"<?php if($current_carrier == 'Metro') { echo ' selected'; } ?>>Metro PCS</option>
<option value="Nextel"<?php if($current_carrier == 'Nextel') { echo ' selected'; } ?>>Nextel</option>
<option value="PacBell"<?php if($current_carrier == 'PacBell') { echo ' selected'; } ?>>Pacific Bell</option>
<option value="Sprint"<?php if($current_carrier == 'Sprint') { echo ' selected'; } ?>>Sprint</option>
<option value="TMobile"<?php if($current_carrier == 'TMobile') { echo ' selected'; } ?>>T-Mobile</option>
<option value="Verizon"<?php if($current_carrier == 'Verizon') { echo ' selected'; } ?>>Verizon</option>
<option value="Virgin"<?php if($current_carrier == 'Virgin') { echo ' selected'; } ?>>Virgin Mobile</option>
</select><br />
<input type="radio" name="text" value="can"<?php if ($current_text == '1') { echo ' checked="yes"'; } ?>>Able to Text<br>
<input type="radio" name="text" value="cant"<?php if ($current_text == '0') { echo ' checked="yes"'; } ?>>Not Able to Text<br>

<br /><hr /><br />
<b><u>Alternate Phone Number</u></b>
<br />
<input type="text" name="altphonechange1" value="<?php echo $current_altacode; ?>" size="1" maxlength="3"><b>-</b><input type="text" name="altphonechange2" value="<?php echo $current_altfirst3; ?>" size="1" maxlength="3"><b>-</b><input type="text" name="altphonechange3" value="<?php echo $current_altlast4; ?>" size="2" maxlength="4"><br>
<b><u>Alternate Carrier</u></b>
<select name="altcarrier" class="my-select">
<option value="Not A Cell Phone"<?php if($current_altcarrier == 'Not A Cell Phone') { echo ' selected'; } ?>>Not A Cell Phone</option>
<option value="Not Listed"<?php if($current_altcarrier == 'Not Listed') { echo ' selected'; } ?>>Not Listed</option>
<option value="Alltel"<?php if($current_altcarrier == 'Alltel') { echo ' selected'; } ?>>Alltel</option>
<option value="ATT"<?php if($current_altcarrier == 'ATT') { echo ' selected'; } ?>>AT&amp;T</option>
<option value="Boost"<?php if($current_altcarrier == 'Boost') { echo ' selected'; } ?>>Boost Mobile</option>
<option value="Helio"<?php if($current_altcarrier == 'Helio') { echo ' selected'; } ?>>Helio</option>
<option value="Metro"<?php if($current_altcarrier == 'Metro') { echo ' selected'; } ?>>Metro PCS</option>
<option value="Nextel"<?php if($current_altcarrier == 'Nextel') { echo ' selected'; } ?>>Nextel</option>
<option value="PacBell"<?php if($current_altcarrier == 'PacBell') { echo ' selected'; } ?>>Pacific Bell</option>
<option value="Sprint"<?php if($current_altcarrier == 'Sprint') { echo ' selected'; } ?>>Sprint</option>
<option value="TMobile"<?php if($current_altcarrier == 'TMobile') { echo ' selected'; } ?>>T-Mobile</option>
<option value="Verizon"<?php if($current_altcarrier == 'Verizon') { echo ' selected'; } ?>>Verizon</option>
<option value="Virgin"<?php if($current_altcarrier == 'Virgin') { echo ' selected'; } ?>>Virgin Mobile</option>
</select><br />
<input type="radio" name="alttext" value="can"<?php if ($current_alttext == '1') { echo ' checked="yes"'; } ?>>Able to Text<br>
<input type="radio" name="alttext" value="cant"<?php if ($current_alttext == '0') { echo ' checked="yes"'; } ?>>Not Able to Text<br>

</td>
</tr>
</table>
<?php
echo '<div align="center"><input type="submit" name="update_users" value="Submit" /><br /><input type="submit" name="delete_user" value="Delete User" /></div>';
include('includes/update_users.php');
include('includes/a_user_delete.php');
echo '</form>';
}
else {
echo 'Please choose an employee and press get info.';
}
}

?>




the script it corrosponds to is




<?php

if(isset($_POST['update_users'])){

$names = trim($_POST['selected']);
$adm_data = mysql_num_rows(mysql_query("SELECT * FROM admins WHERE username = '$names'"));
$acc_data = mysql_fetch_array(mysql_query("SELECT * FROM accounts WHERE name = '$names'"));
$name = $acc_data['name'];
$admin = $acc_data['admin'];
$manager = $acc_data['manager'];
$first = $acc_data['first'];
$last = $acc_data['last'];
$email = $acc_data['email'];
$password = $acc_data['password'];
$current_acode = $acc_data['acode'];
$current_first3 = $acc_data['first3'];
$current_last4 = $acc_data['last4'];
$current_carrier = $acc_data['carrier'];
$current_altacode = $acc_data['altacode'];
$current_altfirst3 = $acc_data['altfirst3'];
$current_altlast4 = $acc_data['altlast4'];
$current_altcarrier = $acc_data['altcarrier'];
$zpassword = sha1($password);
$mpassword = md5($zpassword);
$quotes = "''";
$specquotes = ",''";
$apos = "'";

$desire_user = '0';
$desire_manager = '0';
$desire_admin = '0';
$desire_schedule = '0';
$cantext = '0';
$altcantext = '0';

$stop = "false";

echo '<br /><div align="center">';

if(isset($_POST['choice'])){

$selected_radio = $_POST['choice'];

if ($selected_radio == 'user'){
$desire_user = '1';
}
else if ($selected_radio == 'manager'){
$desire_manager = '1';
}
else if ($selected_radio == 'admin'){
$desire_admin = '1';
}

if($desire_admin == '1'){
if($admin == '0'){
mysql_query("UPDATE accounts SET admin = 1, manager = 1 WHERE name = '$names'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' now has Administrative Acess.<br />';
$stop = "true";
}
}
else if($desire_manager == '1'){
if($manager == '0'){
mysql_query("UPDATE accounts SET admin = 0, manager = 1 WHERE name = '$name'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' now has Managerial Acess.<br />';
$stop = "true";
}
}
else if($desire_user == '1'){
if(($admin == '1') && ($manager == '0')) {
mysql_query("UPDATE accounts SET manager = 0, admin = 0 WHERE name = '$name'");
echo '<font color="green">Regular User Access restored to ' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $quotes . '.<br />';
$stop = "true";
}
}
echo '<br />';
}

if(isset($_POST['schedman'])){
$checked = $_POST['schedman'];
if ($checked == 'yes'){
$desire_schedule = '1';
}

if($desire_schedule == '1'){
if($adm_data != "0"){
mysql_query("DELETE FROM admins WHERE username = '$name'");
echo '<font color="green">' . $quotes . $name . $specquotes . ' is no longer a schedule manager.<br />';
$stop = "true";
} else {
mysql_query("INSERT INTO `admins` (`username`, `password`, `email`) VALUES ('$name', '$mpassword', '$email')");
echo '<font color="green">' . $quotes . $name . $specquotes . ' is now a schedule manager.';
$stop = "true";
}
}
echo '<br />';
}

if(isset($_POST['phonechange1'])){
$area = $_POST['phonechange1'];
$ifchangedphone1 = $current_acode != $area;
if($ifchangedphone1){
mysql_query("UPDATE accounts SET acode = '$area' WHERE name = '$names'");
echo '<font color="green">Area code for ' . $names . $apos . 's phone number has been changed to ' . $area . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['phonechange2'])){
$first3 = $_POST['phonechange2'];
$ifchangedphone2 = $current_first3 != $first3;
if($ifchangedphone2){
mysql_query("UPDATE accounts SET first3 = '$first3' WHERE name = '$names'");
echo '<font color="green">The First 3 digits for ' . $names . $apos . 's phone number has been changed to ' . $first3 . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['phonechange3'])){
$last4 = $_POST['phonechange3'];
$ifchangedphone3 = $current_last4 != $last4;
if($ifchangedphone3){
mysql_query("UPDATE accounts SET last4 = '$last4' WHERE name = '$names'");
echo '<font color="green">The Last 4 digits for ' . $names . $apos . 's phone number has been changed to ' . $last4 . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['carrier'])){
$new_carrier = trim($_POST['carrier']);
$ifchangedcarrier = $current_carrier != $new_carrier;
if($ifchangedcarrier){
mysql_query("UPDATE accounts SET carrier = '$new_carrier' WHERE name = '$names'");
echo '<font color="green">The Service Carrier for ' . $names . ' has been changed from ' . $current_carrier . ' to ' . $new_carrier . '.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['text'])){

$selected_radio = $_POST['text'];

if ($selected_radio == 'can'){
$cantext = '1';
}
else if ($selected_radio == 'cant'){
$cantext = '0';
}

if($cantext == '1'){
mysql_query("UPDATE accounts SET text = 1 WHERE name = '$names'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' is now able to be texted from the site.<br />';
$stop = "true";
}

else if($cantext == '0') {
mysql_query("UPDATE accounts SET text = 0 WHERE name = '$names'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' is no longer able to be texted from the site.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['altphonechange1'])){
$altarea = $_POST['altphonechange1'];
$ifchangedphone1 = $current_acode != $altarea;
if($ifchangedphone1){
mysql_query("UPDATE accounts SET acode = '$altarea' WHERE name = '$names'");
echo '<font color="green">Area code for ' . $names . $apos . 's phone number has been changed to ' . $altarea . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['altphonechange2'])){
$altfirst3 = $_POST['altphonechange2'];
$ifchangedphone2 = $current_first3 != $altfirst3;
if($ifchangedphone2){
mysql_query("UPDATE accounts SET first3 = '$altfirst3' WHERE name = '$names'");
echo '<font color="green">The First 3 digits for ' . $names . $apos . 's phone number has been changed to ' . $altfirst3 . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['altphonechange3'])){
$altlast4 = $_POST['altphonechange3'];
$ifchangedphone3 = $current_last4 != $altlast4;
if($ifchangedphone3){
mysql_query("UPDATE accounts SET last4 = '$altlast4' WHERE name = '$names'");
echo '<font color="green">The Last 4 digits for ' . $names . $apos . 's phone number has been changed to ' . $altlast4 . ', please press the ' . $quotes . 'get info' . $quotes . ' button for ' . $names . ' to view changes.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['altcarrier'])){
$new2_carrier = trim($_POST['altcarrier']);
$ifchangedcarrier = $current_carrier != $new2_carrier;
if($ifchangedcarrier){
mysql_query("UPDATE accounts SET carrier = '$new2_carrier' WHERE name = '$names'");
echo '<font color="green">The Service Carrier for ' . $names . ' has been changed from ' . $current_carrier . ' to ' . $new_carrier . '.<br />';
$stop = "true";
}
echo '<br />';
}

if(isset($_POST['alttext'])){

$selected_radio = $_POST['alttext'];

if ($selected_radio == 'can'){
$altcantext = '1';
}
else if ($selected_radio == 'cant'){
$altcantext = '0';
}

if($altcantext == '1'){
mysql_query("UPDATE accounts SET alttext = 1 WHERE name = '$names'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' is now able to be texted from the site with their alternate phone number.<br />';
$stop = "true";
} else if($altcantext == '0'){

mysql_query("UPDATE accounts SET alttext = 0 WHERE name = '$names'");
echo '<font color="green">' . $first . ' ' . $last . ', owner of account ' . $quotes . $name . $specquotes . ' is no longer able to be texted from the site with their alternate phone number.<br />';
$stop = "true";
}
echo '<br />';
}

echo '</font></div>';
}

?>



when you press either submit or delete it doesnt do anything but return me to a postion that looks like i never started and it doesnt update mysql. if anyone can help its greatly appreciated =) thank you

abduraooft
01-13-2010, 08:40 AM
Add proper error check to your queries like

mysql_query("-- your query here ---") or die(mysql_error());



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum