fyi... that was on the original fix i did on my version. I was going to show you an ajaxy version with a button instead of a submit but decided that would take too much time... then I forgot to change it back to a submit button.Obadiah wrote:everah....your a genius...thanks mann:)
much thanks to feyd and space also
replacing values not working anymore
Moderator: General Moderators
i gave you a shout out space
...im not familiar with ajax...although i do hear alot about it here on the boards...oh yea...why did ya change ya avatar mann...wheres the GOAT!!
[edited]
here is the final rewrite of my script yesterday
[edited]
here is the final rewrite of my script yesterday
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
function doDB()
{
$conn = mysql_connect("#####","####","#######") or die(mysql_error());
mysql_select_db("customerdirectory",$conn) or die(mysql_error());
return $conn;
}
function locate($number, $conn)
{
$sql = "SELECT * FROM merchant WHERE phone_num = '" . mysql_real_escape_string($number, $conn) . "'";
$result = mysql_query($sql,$conn) or die(mysql_error());
return $result;
}
$conn = doDB();
echo '<html>
<head>
<title>Merchant Locater</title>
<link rel="stylesheet" type="text/css" href="cs.css">
<script language="javascript">
</script>
</head>
<body>';
echo '<p style="color:blue">Please enter a phone number:
<form method="post" action="' . basename($_SERVER['SCRIPT_FILENAME']) . '" >
<input type="text" name="phone_num">
<input type="hidden" name="action" value="locate">
<input type="submit" name="submit" value="Find Merchant" ></p>
</form>';
if ( isset($_POST['action']) && 'locate' === $_POST['action'] )
{
$result = locate($_POST['phone_num'], $conn);
while ($newArray = mysql_fetch_array($result))
{
$phone_num = $newArray['phone_num'];
$merchant_num = $newArray['merchant_num'];
$date_recieved = $newArray['date_recieved'];
$merchant_name = $newArray['merchant_name'];
$purchase_type = $newArray['purchase_type'];
$lease_score = $newArray['lease_score'];
$amex = $newArray['amex'];
$app_id = $newArray['app_id'];
$discover = $newArray['discover'];
$user_name = $newArray['user_name'];
$check_conversion = $newArray['check_conversion'];
$gift_loyalty = $newArray['gift_loyalty'];
$app_type = $newArray['app_type'];
$terminal = $newArray['terminal'];
$serial_num = $newArray['serial_num'];
$nms = $newArray['nms'];
$ckmerchant_num = $newArray['ckmerchant_num'];
$giftmerchant_num = $newArray['giftmerchant_num'];
$comments = $newArray['comments'];
}
echo '
<form action="status_replace.php" method="post" onsubmit="return validate()">
<table width="683">
<tr>
<td>
<table class="text" width="683" border="1" bgcolor="blue" bordercolor="ivory">
<tr>
<td align="center" width="162">Date Received</td>
<td align="center" width="131">Agent</td>
<td align="center" width="162">Merchant Name</td>
<td align="center" width="94">Phone Number</td>
<td align="center" width="67">Lease Score</td>
</tr>
<tr>
<td><input type="text" name="date_recieved" value="'.$date_recieved.'" size="12"></td>
<td>
<input type="text" name="user_name" value="'.$user_name.'" size="20">
</td>
<td><input type="text" name="merchant_name" value="'.$merchant_name.'" maxlength="50" size="22"></td>
<td>
<input type="text" disabled="disabled" name="phone_num" value="'.$phone_num.'" maxlength="12" size="17">
</td>
<td>
<input type="text" name="lease_score" value="'.$lease_score.'" maxlength="3" size="5">
</td>
</tr>
<tr>
<td align="center" width="162">Application Type</td>
<td align="center" width="131">AMEX</td>
<td align="center" width="162">Discover</td>
<td align="center" width="94">Check Conversion</td>
<td align="center" width="67">Gift & Loyalty</td>
</tr>
<tr>
<td>
<input type="text" name="app_type" value="'.$app_type.'" maxlength="50" size="20">
</td>
<td>
<input type="text" name="amex" value="'.$amex.'" maxlength="3" size="5">
</td>
<td>
<input type="text" name="discover" value="'.$discover.'" maxlength="3" size="5">
</td>
<td>
<input type="text" name="check_conversion" value="'.$check_conversion.'" maxlength="3" size="5">
</td>
<td>
<input type="text" name="gift_loyalty" value="'.$gift_loyalty.'" maxlength="3" size="5">
</td>
</tr>
<tr>
<td align="center" width="162">Merchant #:</td>
<td align="center">Ck Merchant #:</td>
<td align="center">Gift Merchant #:</td>
<td align="center" width="83">Terminal:</td>
</tr>
<tr>
<td><input type="text" name="merchant_num" value="'.$merchant_num.'" size="12" maxlength="12"></td>
<td><input type="text" name="ckmerchant_num" value="'.$ckmerchant_num.'" maxlength="14" size="13"></td>
<td><input type="text" name="giftmerchant_num" value="'.$giftmerchant_num.'" maxlength="8" size="15"></td>
<td><input type="text" name="terminal" value="'.$terminal.'" size="17"></td>
</tr>
<tr>
<td align="center" width="162">Serial#/SiteID/TID:</td>
<td align="center" width="131">DL#/NMS:</td>
<td align="center" width="162">App-ID:</td>
<td align="center" width="162">L/C/R:</td>
</tr>
<tr>
<td><input type="text" name="serial_num" value="'.$serial_num.'" size="22" maxlength="15"></td>
<td><input type="text" name="nms" size="12" value="'.$nms.'" maxlength="12"></td>
<td><input type="text" name="app_id" size="22" value="'.$app_id.'" maxlength="10"></td>
<td>
<input type="text" name="purchase_type" size="22" value="'.$purchase_type.'" maxlength="10">
</td>
</tr>
<tr>
<td>Comments</td>
<td colspan="11"><textarea name="comments" value="'.nl2br($comments).'" cols=55 rows=5></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Update Merchant">
</form>';
}
else
{
echo "nothing to display";
}
?>
Last edited by Obadiah on Thu Dec 07, 2006 10:18 am, edited 2 times in total.
i swear i had this working perfectly yesterday before i left for home but when i came in today customer service was complaining about 2 errors they got when trying to edit a record on my app...i decided to change the name of thread so as not to give our moddies a hard time in creating a new one...also the script in this specific post works in conjection with the ones you guys were helping me with yesterday...so technically i think this is one of those situations where its cool to change the name and post on...anyways
here is the script thats calling the error
i know...i was just running a test to see if it worked and was gonna input it today since it was working fine yesterday
and today it just craps out on me...i dont get it...what in zeuses butthole is wrong here
here is the script thats calling the error
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$conn = mysql_connect("#####","####","########") or die(mysql_error());
mysql_select_db("customerdirectory",$conn) or die(mysql_error());
$next_program = "replaced.php";
$table_name = "merchant";
$sql = "REPLACE INTO $table_name values (
'{$_POST['phone_num']}',
'{$_POST['merchant_num']}',
'{$_POST['date_recieved']}',
'{$_POST['merchant_name']}',
'{$_POST['purchase_type']}',
'{$_POST['lease_score']}',
'{$_POST['amex']}',
'{$_POST['app_id']}',
'{$_POST['discover']}',
'{$_POST['user_name']}',
'{$_POST['check_conversion']}',
'{$_POST['gift_loyalty']}',
'{$_POST['app_type']}',
'{$_POST['terminal']}',
'{$_POST['serial_num']}',
'{$_POST['nms']}',
'{$_POST['ckmerchant_num']}',
'{$_POST['giftmerchant_num']}',
'{$_POST['comments']}',
NOW())";
if(mysql_query($sql, $conn))
{
header("Location: $next_program");
}
else
{
echo 'The phone number you entered already exists. Please check merchant information and try again<br>';
echo "If you feel this message to be an error please contact the web admin<br>";
echo "something went wrong";
}
?>before you guys smurfslap me about the sql sanitationNotice: Undefined index: phone_num in C:\Program Files\status_replace.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\status_replace.php:10) in C:\Program Files\status_replace.php on line 32
and today it just craps out on me...i dont get it...what in zeuses butthole is wrong here
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
$_POST['phone_num'] is not being sent. Do you have anything on the originating form named 'phone_num' ?
The header sent error is correct as the code is printing the error message before the header. Solve this first error and the header problem will also go away.
Although not a current problem... Redirections should be:
Use the full url_path rather than a relative one and exit. If you don't have exit the rest of your code will still process.
The header sent error is correct as the code is printing the error message before the header. Solve this first error and the header problem will also go away.
Although not a current problem... Redirections should be:
Code: Select all
header("Location: $full_url");
exit;i will try the header you suggested but as for the phone number part yea...look the textbox that has the phone number is this
Code: Select all
echo '<input type="text" disabled="disabled" name="phone_num" value="'.$phone_num.'" maxlength="12" size="17">';- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
For testing, do a
Before the query to see what PHP is seeing.
Code: Select all
<?php
echo '<pre>';
var_dump($_POST);
echo '</pre>';
?>i got this back

but i have it everywhere it needs to be...its in the array first taking it from the db
then in the form displaying it and shooting it back for the update
i even took outr the disabled property to see if that would change matters but it did the same thing
hes right...seems weird but for some reason the phone number isnt going througharray(19) {
["date_recieved"]=>
string(10) "10/07/2006"
["user_name"]=>
string(9) "CDean2011"
["merchant_name"]=>
string(9) "ABC Shoes"
["lease_score"]=>
string(2) "A+"
["app_type"]=>
string(13) "Hotel/Lodging"
["amex"]=>
string(2) "No"
["discover"]=>
string(2) "No"
["check_conversion"]=>
string(3) "Yes"
["gift_loyalty"]=>
string(3) "Yes"
["merchant_num"]=>
string(12) "286604366000"
["ckmerchant_num"]=>
string(14) "631-565414-963"
["giftmerchant_num"]=>
string(0) ""
["terminal"]=>
string(8) "omni3750"
["serial_num"]=>
string(7) "7230000"
["nms"]=>
string(11) "800-000-000"
["app_id"]=>
string(7) "ueva231"
["purchase_type"]=>
string(5) "Lease"
["comments"]=>
string(0) ""
["submit"]=>
string(15) "Update Merchant"
}
Notice: Undefined index: phone_num in C:\Program Files\xampp\htdocs\PHP\reps\status_replace.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\PHP\reps\status_replace.php:2) in C:\Program Files\xampp\htdocs\PHP\reps\status_replace.php on line 37
but i have it everywhere it needs to be...its in the array first taking it from the db
Code: Select all
while ($newArray = mysql_fetch_array($result))
{
$phone_num = $newArray['phone_num'];Code: Select all
echo'<input type="text" disabled="disabled" name="phone_num" value="'.$phone_num.'" maxlength="12" size="17">';
Last edited by Obadiah on Thu Dec 07, 2006 10:51 am, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Note: the input field is disabled so no value is being sent.Obadiah wrote:i will try the header you suggested but as for the phone number part yea...look the textbox that has the phone number is thisCode: Select all
echo '<input type="text" disabled="disabled" name="phone_num" value="'.$phone_num.'" maxlength="12" size="17">';
D'oh...i didnt clear my cookies...it worked when i took off the disabled this time...but i still get the header error
i got this for my header redirect
i got this for my header redirect
Code: Select all
$next_program = "replaced.php";Code: Select all
header("Location: $next_program");
exit;
Last edited by Obadiah on Thu Dec 07, 2006 10:57 am, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Something is being outputted (echo/print_r/before <?php tag) before the header. This is not allowed... Loads of topics on this subject if you do a search. Even one in tutorial section... viewtopic.php?t=1157