jeaker Posted December 21, 2008 Share Posted December 21, 2008 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. Notice: Undefined index: sameaddress in /www/blah.com/web/www/dev3/newuser2.php on line 45 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. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted December 21, 2008 Share Posted December 21, 2008 to me it does not look like you are passing a value from the form for sameaddress. if you are can you point out the line to me. Quote Link to comment Share on other sites More sharing options...
jeaker Posted December 21, 2008 Author Share Posted December 21, 2008 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" /> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.