Jump to content

jeaker

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jeaker's Achievements

Member

Member (2/5)

0

Reputation

  1. I figure out the session thing, and it worked. Thank you both so much for your help!!
  2. I have tryed that. Its still gives me the erroer message Everything works like it should it just puts the message on the top of the page.
  3. I have never used sessions to pass check box information.
  4. This is the entire code for the page that has the check box on it. <?php include 'unsecure.php'; include 'header.php'; if(isset($_GET['fname'])) { $fname = $_GET['fname']; } else { $fname = ''; } if(isset($_GET['lname'])) { $lname = $_GET['lname']; } else { $lname = ''; } if(isset($_GET['email'])) { $email = $_GET['email']; } else { $email = ''; } if(isset($_GET['address'])) { $address = $_GET['address']; } else { $address = ''; } if(isset($_GET['address2'])) { $address2 = $_GET['address2']; } else { $address2 = ''; } if(isset($_GET['city'])) { $city = $_GET['city']; } else { $city = ''; } if(isset($_GET['state'])) { $state = $_GET['state']; } else { $state = ''; } if(isset($_GET['zip'])) { $zip = $_GET['zip']; } else { $zip = ''; } if(isset($_GET['billaddress'])) { $billaddress = $_GET['billaddress']; } else { $billaddress = ''; } if(isset($_GET['billaddress2'])) { $billaddress2 = $_GET['billaddress2']; } else { $billaddress2 = ''; } if(isset($_GET['billcity'])) { $billcity = $_GET['billcity']; } else { $billcity = ''; } if(isset($_GET['billstate'])) { $billstate = $_GET['billstate']; } else { $billstate = ''; } if(isset($_GET['billzip'])) { $billzip = $_GET['billzip']; } else { $billzip = ''; } ?> <tr> <td height="100%" rowspan="2" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: 0033CC" height="100%" align="center"> <tr> <td width="14"><img src="images/tl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/tr_blu.gif" width="14" height="14" border="0"></td> </tr> <tr> <td height="100%"></td> <td height="100%" colspan="3" align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: FF9900" height="100%"> <tr> <td width="14"><img src="images/tl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/tr_blkblu.gif" width="14" height="14" border="0"></td> </tr> <tr valign="top" height="100%"> <td style="background-color: 000000"></td> <td height="100%" style="background-color: 000000" align="center" valign="top"> <table border="0" bgcolor="white" cellspacing="0" height="100%" width="100%"> <tr valign="top"> <td bgcolor="black" valign="top"> <table width="100%" class="bluetext" cellpadding="5" cellspacing="5" height="100%"> <tr valign="top"> <td width="100%" class="bluetext" height="100%" valign="top"> <p class="heading">New User Account</p> <p class="bluetext">Welcome to the J.A.C.K.S. family. We hope you'll have a great time here and find everything you're looking for. To get started, just fill out the following information. If you already have an account, please log in on the right.</p> <?php if(isset($_GET['msg'])) { $msg = $_GET['msg']; echo '<p class="redtext">'; switch($msg) { case 1: echo "There is already an account registered with this e-mail address. Please log in on the right, or <a class='whitetext' href='retrievepassword.php?email=$email'>click here</a> to retrieve your password."; break; case 2: echo "Please fill in all required fields."; break; case 3: echo "Passwords entered do not match. Please ensure that both password fields are exactly the same."; break; case 4: echo "No accounts match that login info. Please try again on the right, or <a class='whitetext' href='retrievepassword.php?email=$email'>click here to retrieve your password."; break; case 5: echo "If checking the box indicating billing and shipping info are the same, leave billing info blank."; break; } echo '</p>'; } ?> <form action="newuser2.php" method="post" name="Newuser"> <table class="bluetext" align="center"> <tr> <td class="whitetext" colspan="2">Personal Info</td> </tr> <tr> <td width="130">First name:</td> <td><input type='text' name='fname' id='fname' <?php if(isset($_GET['fname'])) echo "value='$fname'";?> /></td> </tr> <tr> <td>Last name:</td> <td><input type="text" name="lname" id="lname" <?php if(isset($_GET['lname'])) echo "value='$lname'";?> /></td> </tr> <tr> <td>E-mail address:</td> <td><input type="text" name="email" id="email" <?php if(isset($_GET['email'])) echo "value='$email'";?> /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td>Verify password:</td> <td><input type="password" name="password2" id="password2" /></td> </tr> <tr> <td class="whitetext" colspan="2">Shipping Info</td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" id="address" <?php if(isset($_GET['address'])) echo "value='$address'";?> /></td> </tr> <tr> <td> </td> <td><input type="text" name="address2" id="address2" <?php if(isset($_GET['address2'])) echo "value='$address2'";?> /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" id="city" <?php if(isset($_GET['city'])) echo "value='$city'";?> /></td> </tr> <tr> <td>State:</td> <td><select name="state" id="state"> <option value=""> </option> <?php $statequery = "SELECT statename, stateabbr FROM state"; $stateresult = mysql_query($statequery); $statecount = 0; while($staterow = mysql_fetch_array($stateresult, MYSQL_BOTH)) { echo '<option value="' . $staterow['stateabbr']; if(isset($_GET['state'])) { if($_GET['state'] == $staterow['stateabbr']) { echo '" selected = "selected'; } } echo '">' . $staterow['statename'] . "</option>"; $statecount = $statecount + 1; } ?> </select> </td> </tr> <tr> <td>Zip code:</td> <td><input type="text" name="zip" id="zip" <?php if(isset($_GET['zip'])) echo "value='$zip'";?> /></td> </tr> <tr> <td class="whitetext" colspan="2">Billing Info<br /> <input type="checkbox" onclick=" if (this.checked) { document.getElementById('tb').style.display='none'; } else { document.getElementById('tb').style.display='inline'; } return true;" name="sameaddress" value="sameaddress" />Check here if billing and shipping info are the same </td> </tr> <tr> <td colspan="2"> <table class="bluetext" align="center" id="tb" width="100%"> <tr> <td width="126">Address:</td> <td><input type="text" name="billaddress" id="billaddress" <?php if(isset($_GET['billaddress'])) echo "value='$billaddress'";?> /></td> </tr> <tr> <td> </td> <td><input type="text" name="billaddress2" id="billaddress2" <?php if(isset($_GET['billaddress2'])) echo "value='$billaddress2'";?> /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="billcity" id="billcity" <?php if(isset($_GET['billcity'])) echo "value='$billcity'";?> /></td> </tr> <tr> <td>State:</td> <td><select name="billstate" id="billstate"> <option value=""> </option> <?php $stateresult = mysql_query($statequery); $statecount = 0; while($staterow = mysql_fetch_array($stateresult, MYSQL_BOTH)) { echo '<option value="' . $staterow['stateabbr'] . '"'; if($billstate == $staterow['stateabbr']) { echo '" selected = "selected'; } echo '">' . $staterow['statename'] . "</option>"; $statecount = $statecount + 1; } ?> </select> </td> </tr> <tr> <td>Zip code:</td> <td><input type="text" name="billzip" id="billzip" <?php if(isset($_GET['billzip'])) echo "value='$billzip'";?> /></td> </tr></table></td></tr> <tr> <td colspan="2" align="center"><input type="Submit" name="Submit" value="Submit" /></td> </tr> </table> </form> </td> </tr> </table> </td> </tr> </table> </td> <td style="background-color: 000000"></td> </tr> <tr> <td width="14"><img src="images/bl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/br_blkblu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td height="100%"></td> </tr> <tr> <td width="14"><img src="images/bl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/br_blu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td valign="top" width="218"> <?php include 'sidebar.php'; ?> </td> </tr> And this is the code that the check box is passed to. <?php include 'unsecure.php'; checksession(); $msg = '<br />'; $query = "SELECT UserID, Email FROM User WHERE Email = '" . $_POST['email'] . "'"; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $password = md5($_POST['password']); $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $billaddress = $_POST['billaddress']; $billaddress2 = $_POST['billaddress2']; $billcity = $_POST['billcity']; $billstate = $_POST['billstate']; $billzip = $_POST['billzip']; $securitycode = md5($email . $zip); $msg .= $query . '<br />'; $result = mysql_query($query); $row = mysql_fetch_array($result); if($row) { header("location:newuser.php?msg=1&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] == '' || $_POST['email'] == '' || $_POST['fname'] == '') { header("location:newuser.php?msg=2&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] != $_POST['password2']) { header("location:newuser.php?msg=3&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['sameaddress'] == 'on') { //Billing address checker activated. if($billaddress != '' || $billaddress2 != '' || $billcity != '' || $billstate != '' || $billzip != '') { // Billing address fields are filled in, it's illegal. if($address != '' || $address2 != '' || $city != '' || $state != '' || $zip != '') { // They also filled in one of the other fields, this is very illegal. header("location:newuser.php?msg=5&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } } } $msg .= 'Success: contact not found. Proceeding.</br >'; $userquery = "INSERT INTO User (FirstName, LastName, Email, Password, securitycode) VALUES ('$fname', '$lname', '$email', '$password', '$securitycode')"; $msg .= $userquery . '<br />'; if(mysql_query($userquery)or die('Error : ' . mysql_error())) { $userid = mysql_insert_id(); $shipquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$address', '$address2', '$city', '$state', '$zip')"; $msg .= $shipquery . '<br />'; if(mysql_query($shipquery) or die('Error : ' . mysql_error())) { $shipid = mysql_insert_id(); $billquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$billaddress', '$billaddress2', '$billcity', '$billstate', '$billzip')"; $msg .= $billquery . '<br />'; if(mysql_query($billquery) or die('Error : ' . mysql_error())) { $billid = mysql_insert_id(); $userquery2 = "UPDATE User SET shipaddress = '$shipid', billaddress = '$billid' WHERE UserID = '$userid'"; $msg .= $userquery2 . '<br />'; if(mysql_query($userquery2) or die('Error : ' . mysql_error())) { $msg .= 'All operations successful! User added.'; } else { $msg .= 'Userquery2 failed.<br />'; } } else { $msg .= 'Billing query failed.<br />'; } } else { $msg .= 'Shipping query failed.<br />'; } } else { $msg .= 'Userquery failed.<br />'; } include 'header.php'; ?> <style type="text/css"> .heading { color:#0033CC; font-family: "Comic Sans MS", sans-serif; font-size:18px; font-weight:bold; text-align:center; } .bluetext { color:#0033CC; font-family: "Comic Sans MS", "Arial", sans-serif; font-size:smaller; font-weight:bold; text-align:left; } </style> <tr> <td height="100%" rowspan="2" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: 0033CC" height="100%" align="center"> <tr> <td width="14"><img src="images/tl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/tr_blu.gif" width="14" height="14" border="0"></td> </tr> <tr> <td height="100%"></td> <td height="100%" colspan="3" align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: FF9900" height="100%"> <tr> <td width="14"><img src="images/tl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/tr_blkblu.gif" width="14" height="14" border="0"></td> </tr> <tr valign="top" height="100%"> <td style="background-color: 000000"></td> <td height="100%" style="background-color: 000000" align="center" valign="top"> <table border="0" bgcolor="white" cellspacing="0" height="100%" width="100%"> <tr valign="top"> <td bgcolor="black" valign="top"> <table width="100%" cellpadding="5" cellspacing="5" height="100%"> <tr valign="top"> <td width="100%" class="bluetext" height="100%" valign="top"> <p class="heading">MY SHOPPING BAG </p> Items currently in your shopping bag: <?php echo $msg; ?></td> </tr> </table> </td> </tr> </table> </td> <td style="background-color: 000000"></td> </tr> <tr> <td width="14"><img src="images/bl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/br_blkblu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td height="100%"></td> </tr> <tr> <td width="14"><img src="images/bl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/br_blu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td valign="top" width="218"> <?php include 'sidebar.php'; ?> </td> </tr>
  5. I am having trouble passing a checkbox "samadress" to another page using POST. Here is a little snippit of code. <td class="whitetext" colspan="2">Billing Info<br /> <input type="checkbox" onclick=" if (this.checked) { document.getElementById('tb').style.display='none'; } else { document.getElementById('tb').style.display='inline'; } return true;" name="sameaddress" value="sameaddress" />Check here if billing and shipping info are the same </td> What this basicly does is give a checkbox, and if that box is checked it will make the table underneath it dissapear. That all works fine, my problem is, I cannot get "sameaddress" to pass to my next php page where I want to be able to tell if the box was checked or not. Using the below code. else if($_POST['sameaddress'] == 'on') LINE 45 When I execute my pages I get; Line 45 is denoted above. If anyone can tell me what I am doing wrong it would be a great help.
  6. This is where i was attempting to pass "sameaddress" using JAVA, but as you can probably tell I am not the best at it. <input type="checkbox" onclick=" if (this.checked) { document.getElementById('tb').style.display='none'; } else { document.getElementById('tb').style.display='inline'; } return true;" name="sameaddress" id="sameaddress" />
  7. I have been staring at this code for too long, I need a fresh set of eyes to help me out. I have been getting this error message. Here is the code from newuser2.php. <?php include 'unsecure.php'; checksession(); $msg = '<br />'; $query = "SELECT UserID, Email FROM User WHERE Email = '" . $_POST['email'] . "'"; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $password = md5($_POST['password']); $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $billaddress = $_POST['billaddress']; $billaddress2 = $_POST['billaddress2']; $billcity = $_POST['billcity']; $billstate = $_POST['billstate']; $billzip = $_POST['billzip']; $securitycode = md5($email . $zip); $msg .= $query . '<br />'; $result = mysql_query($query); $row = mysql_fetch_array($result); if($row) { header("location:newuser.php?msg=1&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] == '' || $_POST['email'] == '' || $_POST['fname'] == '') { header("location:newuser.php?msg=2&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] != $_POST['password2']) { header("location:newuser.php?msg=3&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['sameaddress'] == 'on') { //Billing address checker activated. if($billaddress != '' || $billaddress2 != '' || $billcity != '' || $billstate != '' || $billzip != '') { // Billing address fields are filled in, it's illegal. if($address != '' || $address2 != '' || $city != '' || $state != '' || $zip != '') { // They also filled in one of the other fields, this is very illegal. header("location:newuser.php?msg=5&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } } } $msg .= 'Success: contact not found. Proceeding.</br >'; $userquery = "INSERT INTO User (FirstName, LastName, Email, Password, securitycode) VALUES ('$fname', '$lname', '$email', '$password', '$securitycode')"; $msg .= $userquery . '<br />'; if(mysql_query($userquery)or die('Error : ' . mysql_error())) { $userid = mysql_insert_id(); $shipquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$address', '$address2', '$city', '$state', '$zip')"; $msg .= $shipquery . '<br />'; if(mysql_query($shipquery) or die('Error : ' . mysql_error())) { $shipid = mysql_insert_id(); $billquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$billaddress', '$billaddress2', '$billcity', '$billstate', '$billzip')"; $msg .= $billquery . '<br />'; if(mysql_query($billquery) or die('Error : ' . mysql_error())) { $billid = mysql_insert_id(); $userquery2 = "UPDATE User SET shipaddress = '$shipid', billaddress = '$billid' WHERE UserID = '$userid'"; $msg .= $userquery2 . '<br />'; if(mysql_query($userquery2) or die('Error : ' . mysql_error())) { $msg .= 'All operations successful! User added.'; } else { $msg .= 'Userquery2 failed.<br />'; } } else { $msg .= 'Billing query failed.<br />'; } } else { $msg .= 'Shipping query failed.<br />'; } } else { $msg .= 'Userquery failed.<br />'; } include 'header.php'; ?> And here is the code form newuser.php. This is where newuser2.php pulls some of its input. <?php include 'unsecure.php'; include 'header.php'; // $sessionid = session_id(); // session_start(); // $_SESSION['id'] = session_id(); // $_SESSION['hiya'] = "hiya"; if(isset($_GET['fname'])) { $fname = $_GET['fname']; } else { $fname = ''; } if(isset($_GET['lname'])) { $lname = $_GET['lname']; } else { $lname = ''; } if(isset($_GET['email'])) { $email = $_GET['email']; } else { $email = ''; } if(isset($_GET['address'])) { $address = $_GET['address']; } else { $address = ''; } if(isset($_GET['address2'])) { $address2 = $_GET['address2']; } else { $address2 = ''; } if(isset($_GET['city'])) { $city = $_GET['city']; } else { $city = ''; } if(isset($_GET['state'])) { $state = $_GET['state']; } else { $state = ''; } if(isset($_GET['zip'])) { $zip = $_GET['zip']; } else { $zip = ''; } if(isset($_GET['billaddress'])) { $billaddress = $_GET['billaddress']; } else { $billaddress = ''; } if(isset($_GET['billaddress2'])) { $billaddress2 = $_GET['billaddress2']; } else { $billaddress2 = ''; } if(isset($_GET['billcity'])) { $billcity = $_GET['billcity']; } else { $billcity = ''; } if(isset($_GET['billstate'])) { $billstate = $_GET['billstate']; } else { $billstate = ''; } if(isset($_GET['billzip'])) { $billzip = $_GET['billzip']; } else { $billzip = ''; } if(isset($_GET['sameaddress'])) { $sameaddress = $_GET['sameaddress']; } else { $sameadress = ''; } ?> <tr> <td height="100%" rowspan="2" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: 0033CC" height="100%" align="center"> <tr> <td width="14"><img src="images/tl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/tr_blu.gif" width="14" height="14" border="0"></td> </tr> <tr> <td height="100%"></td> <td height="100%" colspan="3" align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: FF9900" height="100%"> <tr> <td width="14"><img src="images/tl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/tr_blkblu.gif" width="14" height="14" border="0"></td> </tr> <tr valign="top" height="100%"> <td style="background-color: 000000"></td> <td height="100%" style="background-color: 000000" align="center" valign="top"> <table border="0" bgcolor="white" cellspacing="0" height="100%" width="100%"> <tr valign="top"> <td bgcolor="black" valign="top"> <table width="100%" class="bluetext" cellpadding="5" cellspacing="5" height="100%"> <tr valign="top"> <td width="100%" class="bluetext" height="100%" valign="top"> <p class="heading">New User Account</p> <p class="bluetext">Welcome to the J.A.C.K.S. family. We hope you'll have a great time here and find everything you're looking for. To get started, just fill out the following information. If you already have an account, please log in on the right.</p> <?php if(isset($_GET['msg'])) { $msg = $_GET['msg']; echo '<p class="redtext">'; switch($msg) { case 1: echo "There is already an account registered with this e-mail address. Please log in on the right, or <a class='whitetext' href='retrievepassword.php?email=$email'>click here</a> to retrieve your password."; break; case 2: echo "Please fill in all required fields."; break; case 3: echo "Passwords entered do not match. Please ensure that both password fields are exactly the same."; break; case 4: echo "No accounts match that login info. Please try again on the right, or <a class='whitetext' href='retrievepassword.php?email=$email'>click here to retrieve your password."; break; case 5: echo "If checking the box indicating billing and shipping info are the same, leave billing info blank."; break; } echo '</p>'; } ?> <form action="newuser2.php" method="post" name="Newuser"> <table class="bluetext" align="center"> <tr> <td class="whitetext" colspan="2">Personal Info</td> </tr> <tr> <td width="130">First name:</td> <td><input type='text' name='fname' id='fname' <?php if(isset($_GET['fname'])) echo "value='$fname'";?> /></td> </tr> <tr> <td>Last name:</td> <td><input type="text" name="lname" id="lname" <?php if(isset($_GET['lname'])) echo "value='$lname'";?> /></td> </tr> <tr> <td>E-mail address:</td> <td><input type="text" name="email" id="email" <?php if(isset($_GET['email'])) echo "value='$email'";?> /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td>Verify password:</td> <td><input type="password" name="password2" id="password2" /></td> </tr> <tr> <td class="whitetext" colspan="2">Shipping Info</td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" id="address" <?php if(isset($_GET['address'])) echo "value='$address'";?> /></td> </tr> <tr> <td> </td> <td><input type="text" name="address2" id="address2" <?php if(isset($_GET['address2'])) echo "value='$address2'";?> /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" id="city" <?php if(isset($_GET['city'])) echo "value='$city'";?> /></td> </tr> <tr> <td>State:</td> <td><select name="state" id="state"> <option value=""> </option> <?php $statequery = "SELECT statename, stateabbr FROM state"; $stateresult = mysql_query($statequery); $statecount = 0; while($staterow = mysql_fetch_array($stateresult, MYSQL_BOTH)) { echo '<option value="' . $staterow['stateabbr']; if(isset($_GET['state'])) { if($_GET['state'] == $staterow['stateabbr']) { echo '" selected = "selected'; } } echo '">' . $staterow['statename'] . "</option>"; $statecount = $statecount + 1; } ?> </select> </td> </tr> <tr> <td>Zip code:</td> <td><input type="text" name="zip" id="zip" <?php if(isset($_GET['zip'])) echo "value='$zip'";?> /></td> </tr> <tr> <td class="whitetext" colspan="2">Billing Info<br /> <input type="checkbox" onclick=" if (this.checked) { document.getElementById('tb').style.display='none'; } else { document.getElementById('tb').style.display='inline'; } return true;" name="sameaddress" id="sameaddress" />Check here if billing and shipping info are the same </td> </tr> <tr> <td colspan="2"> <table class="bluetext" align="center" id="tb" width="100%"> <tr> <td width="126">Address:</td> <td><input type="text" name="billaddress" id="billaddress" <?php if(isset($_GET['billaddress'])) echo "value='$billaddress'";?> /></td> </tr> <tr> <td> </td> <td><input type="text" name="billaddress2" id="billaddress2" <?php if(isset($_GET['billaddress2'])) echo "value='$billaddress2'";?> /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="billcity" id="billcity" <?php if(isset($_GET['billcity'])) echo "value='$billcity'";?> /></td> </tr> <tr> <td>State:</td> <td><select name="billstate" id="billstate"> <option value=""> </option> <?php $stateresult = mysql_query($statequery); $statecount = 0; while($staterow = mysql_fetch_array($stateresult, MYSQL_BOTH)) { echo '<option value="' . $staterow['stateabbr'] . '"'; if($billstate == $staterow['stateabbr']) { echo '" selected = "selected'; } echo '">' . $staterow['statename'] . "</option>"; $statecount = $statecount + 1; } ?> </select> </td> </tr> <tr> <td>Zip code:</td> <td><input type="text" name="billzip" id="billzip" <?php if(isset($_GET['billzip'])) echo "value='$billzip'";?> /></td> </tr></table></td></tr> <tr> <td colspan="2" align="center"><input type="Submit" name="Submit" value="Submit" /></td> </tr> </table> </form> </td> </tr> </table> </td> </tr> </table> </td> <td style="background-color: 000000"></td> </tr> <tr> <td width="14"><img src="images/bl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/br_blkblu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td height="100%"></td> </tr> <tr> <td width="14"><img src="images/bl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/br_blu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td valign="top" width="218"> Sorry for so much code, but I have been looking at this for hours and I can't figure this out. Thank you for any help.
  8. I have the unwanted task of taking someone else's code and making it actually work. I have been fairly successful so far. However, this particular page has given me a fit. It all looks great to me but will not right anything to the database. Everything on the database side is correct because it functions properly with every other page. If there is any comments or suggestion, I would appreciate them. Thank you in advance. <?php include 'unsecure.php'; checksession(); //echo dumpvars(); // $msg = '<br />'; $query = "SELECT UserID, Email FROM User WHERE Email = '" . $_POST['email'] . "'"; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $password = md5($_POST['password']); $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $billaddress = $_POST['billaddress']; $billaddress2 = $_POST['billaddress2']; $billcity = $_POST['billcity']; $billstate = $_POST['billstate']; $billzip = $_POST['billzip']; $securitycode = md5($email . $zip); $msg .= $query . '<br />'; $result = mysql_query($query); $row = mysql_fetch_array($result); if($row) { header("location:newuser.php?msg=1&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] == '' || $_POST['email'] == '' || $_POST['fname'] == '') { header("location:newuser.php?msg=2&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] != $_POST['password2']) { header("location:newuser.php?msg=3&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['sameaddress'] == 'on') { //Billing address checker activated. if($billaddress != '' || $billaddress2 != '' || $billcity != '' || $billstate != '' || $billzip != '') { // Billing address fields are filled in, it's illegal. if($address != '' || $address2 != '' || $city != '' || $state != '' || $zip != '') { // They also filled in one of the other fields, this is very illegal. header("location:newuser.php?msg=5&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } } } $msg .= 'Success: contact not found. Proceeding.</br >'; $userquery = "INSERT INTO User (FirstName, LastName, Email, Password, securitycode) VALUES ('$fname', '$lname', '$email', '$password', '$securitycode')"; $msg .= $userquery . '<br />'; if(mysql_query($userquery)) { $userid = mysql_insert_id(); $shipquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$address', '$address2', '$city', '$state', '$zip')"; $msg .= $shipquery . '<br />'; if(mysql_query($shipquery)) { $shipid = mysql_insert_id(); $billquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$billaddress', '$billaddress2', '$billcity', '$billstate', '$billzip')"; $msg .= $shipquery . '<br />'; if(mysql_query($billquery)) { $billid = mysql_insert_id(); $userquery2 = "UPDATE User SET shipaddress = '$shipid', billaddress = '$billid' WHERE UserID = '$userid'"; $msg .= $userquery2 . '<br />'; if(mysql_query($userquery2)) { $msg .= 'All operations successful! User added.'; } else { $msg .= 'Userquery2 failed.<br />'; } } else { $msg .= 'Billing query failed.<br />'; } } else { $msg .= 'Shipping query failed.<br />'; } } else { $msg .= 'Userquery failed.<br />'; } //$msg .= $userquery; //$query .= $_POST[]; /* */ include 'header.php'; //echo dumpvars(); ?> <style type="text/css"> .heading { color:#0033CC; font-family: "Comic Sans MS", sans-serif; font-size:18px; font-weight:bold; text-align:center; } .bluetext { color:#0033CC; font-family: "Comic Sans MS", "Arial", sans-serif; font-size:smaller; font-weight:bold; text-align:left; } </style> <tr> <td height="100%" rowspan="2" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: 0033CC" height="100%" align="center"> <tr> <td width="14"><img src="images/tl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/tr_blu.gif" width="14" height="14" border="0"></td> </tr> <tr> <td height="100%"></td> <td height="100%" colspan="3" align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: FF9900" height="100%"> <tr> <td width="14"><img src="images/tl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/tr_blkblu.gif" width="14" height="14" border="0"></td> </tr> <tr valign="top" height="100%"> <td style="background-color: 000000"></td> <td height="100%" style="background-color: 000000" align="center" valign="top"> <table border="0" bgcolor="white" cellspacing="0" height="100%" width="100%"> <tr valign="top"> <td bgcolor="black" valign="top"> <table width="100%" cellpadding="5" cellspacing="5" height="100%"> <tr valign="top"> <td width="100%" class="bluetext" height="100%" valign="top"> <p class="heading">MY SHOPPING BAG </p> Items currently in your shopping bag: <?php echo $msg; ?></td> </tr> </table> </td> </tr> </table> </td> <td style="background-color: 000000"></td> </tr> <tr> <td width="14"><img src="images/bl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/br_blkblu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td height="100%"></td> </tr> <tr> <td width="14"><img src="images/bl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/br_blu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td valign="top" width="218"> <?php include 'sidebar.php'; ?> </td> </tr> <?php include 'footer.php'; include 'admin/dbdis.php'; ?>
  9. NIce, Thanks to both of you guys for your help!!!
  10. O, I am putting the data back out via another page. The code on that page looks like this... <body> <?php include 'library/config.php'; include 'library/opendb.php'; $result = mysql_query("SELECT * FROM home"); while($row = mysql_fetch_array($result)) { ?> <div class="content"> <h1><?php echo $row['title']; ?></h1> <br><br> <p><?php echo $row['content']; ?></p> <br> <?php } ?> I apologize if I am a little slow. I am still fairly new to PHP. Is there any particle place in this code to put the nl2br?
  11. I have read alot about that by googleing that.What I don't understand is where it would go?
  12. I have a text field and I want it to make a new like when the user presses enter. What I mean by that is, I have a text field that is populated by info from my database. This information can be edited by the admin. The admin then submits the revesions by clicking update. Is it possible to have the test are recognize the new lines? Here is my code for the text area... <form method="post" action="admin_home.php"> <input type="hidden" name="id" value="1"> <table border="0" cellpadding="2" cellspacing="1" class="box" align="center"> <tr> <td>Title</td> <td><input name="title" type="text" class="box" id="title" value="<?=$title;?>"></td> </tr> <tr> <td>Content</td> <td><textarea name="content" cols="50" rows="10" class="box" id="content"><?=$content;?></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Update Home Page"></td> </tr> </table> </form> and here is the admin_home.php... <?php include 'library/config.php'; include 'library/opendb.php'; if(isset($_GET['id'])) { $query = "SELECT id, title, content ". "FROM home ". "WHERE id = '{$_GET['id']}'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM); $content = htmlspecialchars($content); } else if(isset($_POST['title'])) { $id = $_POST['id']; $title = $_POST['title']; $content = $_POST['content']; if(!get_magic_quotes_gpc()) { $title = addslashes($title); $content = addslashes($content); } // update the article in the database $query = "UPDATE home ". "SET title = '$title', content = '$content' ". "WHERE id = '$id'"; mysql_query($query) or die('Error : ' . mysql_error()); // then remove the cached file $cacheDir = dirname(__FILE__) . '/cache/'; $cacheFile = $cacheDir . '_' . $_GET['id'] . '.html'; @unlink($cacheFile); // and remove the index.html too because the file list // is changed @unlink($cacheDir . 'index.html'); echo "<p align='center'>You have Successfully Updated the Home Page.</p>"; // now we will display $title & content // so strip out any slashes $title = stripslashes($title); $content = stripslashes($content); } include 'library/closedb.php'; ?> If anyone has any ideas, please let me know. Thanks in advance for all the help. You guys are great!
  13. WOW, Thanks btherl for the fresh set of eyes. Been looking at code way too long today.
  14. I have a little problem. I have the below code that gives a list box... <?php // Query the teacher table and load all of the records // into an array. $sql = 'SELECT * FROM teacher'; $res = mysql_query($sql) or die(mysql_error()); while ($rec = mysql_fetch_assoc($res)) $fname[] = $rec; echo '<SELECT name="fname">'; echo "<option></option>\n"; foreach ($fname as $f) echo "<OPTION>{$f['fname']} </OPTION>\n"; echo '</SELECT>'; ?> It list the First name of some teachers. The user is supposed to be able to click DELETE and run the code below.... <?php include 'library/config.php'; include 'library/opendb.php'; $fname=$_POST['fname']; $sql = "DELETE FROM teacher WHERE fname = '$fname'"; mysql_query($query) or die('Error, query failed'); echo "<br>Teacher $fname deleted<br>"; ?> That code is supposed to delete the entire record wherever it finds that first name in the the table 'teacher'. However I continue to get the error "Error, query failed". I know it is probably an error in my sql statement somewhere, but I have been trying for the past 3 hours to get something to work and I have nothing. If anyone has any advice it would be greatly appreciated. Thanks so much!!!
  15. O wow, Stupid mistake on my part. When I said I was getting this... Printed out in my data column. It was the acutaul contents of the text file that I uploaded... Now that I have made a complete fool out of myself. Does anyone have any ideas on what I can display in the "data" part of my table. I do not want it to print out what is in the file. Perhaps just give an indication that there is something uploaded? Also, Is there an easy way to download the file that I have uploaded into the "data" field in my database? THanks again,
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.