hahaha, i apologize everah =). sincerely. thank you for your understanding... here's the code...
Code: Select all
//editCouple.php
<HTML>
<HEAD><TITLE>Edit Couple</TITLE></HEAD>
<BODY>
<CENTER>
<?php $location = "<B>Edit Couple</B>"; ?>
<TABLE BORDER="1" WIDTH="850" CELLPADDING="20">
<TR>
<TD WIDTH="%50" ALIGN="center"><H1>The Very Thing Gifts</H1>
<?php echo $location; ?>
<form method="POST" action="admin1.php?action=view_all">
<input type="SUBMIT" value="View All">
</form>
</TD>
<TD><?php include "admin_search.inc" ?></TD>
</TR>
</TABLE><BR>
<HR WIDTH="300"><BR>
<TABLE WIDTH="750"><TR><TD>
<?php
$status = $_POST['status']; //sent from redirect.php
if(isset($_POST['uID'])){
$uID = $_POST['uID'];
}else{
$uID = $_POST['editID']; //sent from homepage to populate the correct row of information
}
@ $db = mysql_connect("localhost", "apache", "nopass");
if(!$db){
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
mysql_select_db("registry_DB", $db);
//retrieve info from the database
$sql = mysql_query("SELECT * FROM my_search_table WHERE uID LIKE '%". $editID ."%'") or die(mysql_error());
$row = mysql_fetch_array($sql);
if($POST_['status'] != NULL){
echo "<CENTER>". $_POST['status'] ."</CENTER>";
}
//pre-populate input fields with values from the database.
echo "<form action=redirect.php?ID=". $row['uID'] ." method=post>";
echo "<input type=hidden name=ID value=". $row['uID'] .">";
echo "<B>Bride First:</B> <input type=text name=brideFname value=". $row['brideFname'] ."><br />";
echo "<B>Bride Last:</B> <input type=text name=brideLname value=". $row['brideLname'] ."><br />";
echo "<B>Groom First:</B> <input type=text name=groomFname value=". $row['groomFname'] ."><br />";
echo "<B>Groom Last:</B> <input type=text name=groomLname value=". $row['groomLname'] ."><br /><br />";
echo "<B>Event Date:</B> ". $row['event_month'] ."/". $row['event_day'] ."/". $row['event_year'] ."<br />";
echo "<input type=hidden name=event_month value=". $row['event_month'] .">";
echo "<input type=hidden name=event_day value=". $row['event_day'] .">";
echo "<input type=hidden name=event_year value=". $row['event_year'] .">";
echo "<B>Change event date:</B> ";
?>
<SELECT NAME="event_month2">
<OPTION VALUE="">select a month
<OPTION VALUE="01">January
<OPTION VALUE="02">February
<OPTION VALUE="03">March
<OPTION VALUE="04">April
<OPTION VALUE="05">May
<OPTION VALUE="06">June
<OPTION VALUE="07">July
<OPTION VALUE="08">August
<OPTION VALUE="09">September
<OPTION VALUE="10">October
<OPTION VALUE="11">November
<OPTION VALUE="12">December
</SELECT>
<SELECT NAME="event_day2">
<OPTION VALUE="">select a day
<OPTION VALUE="01">01
<OPTION VALUE="02">02
<OPTION VALUE="03">03
<OPTION VALUE="04">04
<OPTION VALUE="05">05
<OPTION VALUE="06">06
<OPTION VALUE="07">07
<OPTION VALUE="08">08
<OPTION VALUE="09">09
<OPTION VALUE="10">10
<OPTION VALUE="11">11
<OPTION VALUE="12">12
<OPTION VALUE="13">13
<OPTION VALUE="14">14
<OPTION VALUE="15">15
<OPTION VALUE="16">16
<OPTION VALUE="17">17
<OPTION VALUE="18">18
<OPTION VALUE="19">19
<OPTION VALUE="20">20
<OPTION VALUE="21">21
<OPTION VALUE="22">22
<OPTION VALUE="23">23
<OPTION VALUE="24">24
<OPTION VALUE="25">25
<OPTION VALUE="26">26
<OPTION VALUE="27">27
<OPTION VALUE="28">28
<OPTION VALUE="29">29
<OPTION VALUE="30">30
<OPTION VALUE="31">31
</SELECT>
<SELECT NAME="event_year2">
<OPTION VALUE="">select a year
<OPTION VALUE="2002">2002
<OPTION VALUE="2003">2003
<OPTION VALUE="2004">2004
<OPTION VALUE="2005">2005
<OPTION VALUE="2006">2006
<OPTION VALUE="2007">2007
<OPTION VALUE="2008">2008
<OPTION VALUE="2009">2009
<OPTION VALUE="2010">2010
</SELECT></TD></TR>
<TR><TD>
<?php
echo "<B>Address:<B> ". $row['ship_add'] .", ". $row['ship_city'] .", ". $row['ship_state'] .", ". $row['ship_zip'] ."<br />";
echo "<input type=hidden name=ship_add value=". $row['ship_add'] .">";
echo "<input type=hidden name=ship_city value=". $row['ship_city'] .">";
echo "<input type=hidden name=ship_state value=". $row['ship_state'] .">";
echo "<input type=hidden name=ship_zip value=". $row['ship_zip'] .">";
echo "<B>Change address information</B><br />";
echo "Street: <input type=text name=ship_add2><br />";
echo "City: <input type=text name=ship_city2><br />";
echo "State: <input type=text name=ship_state2><br />";
echo "Zip Code: <input type=text name=ship_zip2><br />";
$_POST['ID'];
$_POST['brideFname'];
$_POST['brideLname'];
$_POST['groomFname'];
$_POST['groomLname'];
$_POST['ship_add'];
$_POST['ship_city'];
$_POST['ship_state'];
$_POST['ship_zip'];
$_POST['ship_add2'];
$_POST['ship_city2'];
$_POST['ship_state2'];
$_POST['ship_zip2'];
$_POST['event_month'];
$_POST['event_day'];
$_POST['event_year'];
$_POST['event_month2'];
$_POST['event_day2'];
$_POST['event_year2'];
?>
<input type=submit value=Save></form>
</TD></TR></TABLE>
</BODY>
</HTML>
and the next one
Code: Select all
//redirect.php
<?php
$ID = $_POST['ID'];
$brideFname = $_POST['brideFname'];
$brideLname = $_POST['brideLname'];
$groomFname = $_POST['groomFname'];
$groomLname = $_POST['groomLname'];
//if address values changed, replace the variable value
if($_POST['ship_add2'] != NULL){
$ship_add = $_POST['ship_add2'];
}else{
$ship_add = $_POST['ship_add'];
}if($_POST['ship_city2'] != NULL){
$ship_city = $_POST['ship_city2'];
}else{
$ship_city = $_POST['ship_city'];
}if($_POST['ship_state2'] != NULL){
$ship_state = $_POST['ship_state2'];
}else{
$ship_state = $_POST['ship_state'];
}if($_POST['ship_zip2'] != NULL){
$ship_zip = $_POST['ship_zip2'];
}else{
$ship_zip = $_POST['ship_zip'];
}
//if event dates changed, replace the variable value
if($_POST['event_month2'] != NULL){
$event_month = $_POST['event_month2'];
}else{
$event_month = $_POST['event_month'];
}if($_POST['event_day2'] != NULL){
$event_day = $_POST['event_day2'];
}else{
$event_day = $_POST['event_day'];
}if($_POST['event_year2'] != NULL){
$event_year = $_POST['event_year2'];
}else{
$event_year = $_POST['event_year'];
}
@ $db = mysql_connect("localhost", "apache", "nopass");
mysql_select_db("registry_DB", $db);
if(!$db){
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
$sql = "UPDATE my_search_table ".
"SET brideFname = '$brideFname', brideLname = '$brideLname', groomFname = '$groomFname', ".
"groomLname = '$groomLname', event_month = '$event_month', event_day = '$event_day', ".
"event_year = '$event_year', ship_add = '$ship_add', ship_city = '$ship_city', ".
"ship_state = '$ship_state', ship_zip = '$ship_zip' ".
"WHERE uID = '$ID'";
mysql_query($sql) or die(mysql_error());
if(!mysql_query($sql)){
$status = "<font color=red>Your data has not been stored</font>";
}else{$status = "<font color=green>Your data was successfully stored.</font>";
}
$_POST['status'] = $status;
mysql_close($db);
header("Location: /../../../../editCouple.php?editID=". $ID ."");
exit;
?>
the problem is, my input fields (in editCouple.php) are getting truncated before they are processed in the sql query (in redirect.php) at the first sight of whitespace. so, i'll enter "1234 SomeStreet Dr." in the address field. then when i click save, it prints the information... "1234 SomeStreet Dr." perfectly. but let's say now i want to add something into the Name input field, and nothing else. i do, and click save... now the address will print "1234"... and the change has been made to the database... so, i don't know what's going on... it's like this for every input field.
would i do a string manipulation? or somehow alter my sql query to only contain variables inside it. i have no idea how i'd do that, i don't even know if that's the way to fix this issue...