graham23s Posted November 1, 2007 Share Posted November 1, 2007 Hi Guys, in this piece of code: if($_GET['action'] == 'uploadphotos') { if(isset($_POST['submit_2'])) { ## The vars $var_headshot = $_FILES['headshot']['name']; ## Empty submission if(empty($var_headshot)) { stderr("Upload Failed","No photo was uploaded!"); unset($_POST['submit_2']); include("includes/footer.php"); exit; } echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>This photo will appear on your profile as your main one.</b></div><br />'; echo ("<form action=\"myaccount.php?action=uploadphotos\" method=\"POST\" enctype=\"multipart/form-data\" />"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/edit_profile.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Upload Headshot</b></td><td width=\"50%\" align=\"left\"><input type=\"file\" name=\"headshot\" size=\"40\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit_2\" value=\"Upload Headshot\"></td>"); echo ("</tr>"); echo ("</table>"); } // End post isset when a user selects a photo to upload (or not) i am trying to echo back an error (which it does ok) but when i go back or select the "uploadphotos" button the form doesn't display! i have to delete the $_POST['submit_2;] part then reload, i take it, it's because i am setting the variable 'submit_2' would that be right? so if the user doesn't upload a photo i wanted to echo the error and return them back to the form to have it displayed, i tried unset but it never worked is there something i can do to fix this? thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/ Share on other sites More sharing options...
kenrbnsn Posted November 1, 2007 Share Posted November 1, 2007 The "exit" stops your script. Remove it. Ken Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/#findComment-382713 Share on other sites More sharing options...
graham23s Posted November 1, 2007 Author Share Posted November 1, 2007 Hi Mate, removed that bit and just left: if($_GET['action'] == 'uploadphotos') { if(isset($_POST['submit_2'])) { ## The vars $var_headshot = $_FILES['headshot']['name']; ## Empty submission if(empty($var_headshot)) { stderr("Upload Failed","No photo was uploaded!"); unset($_POST['submit_2']); } echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>This photo will appear on your profile as your main one.</b></div><br />'; echo ("<form action=\"myaccount.php?action=uploadphotos\" method=\"POST\" enctype=\"multipart/form-data\" />"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/edit_profile.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Upload Headshot</b></td><td width=\"50%\" align=\"left\"><input type=\"file\" name=\"headshot\" size=\"40\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit_2\" value=\"Upload Headshot\"></td>"); echo ("</tr>"); echo ("</table>"); } // End post isset when i re-select upload photos the form still isn't displayed? is there anything else i could try? cheers mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/#findComment-382896 Share on other sites More sharing options...
roopurt18 Posted November 1, 2007 Share Posted November 1, 2007 The code you've shown us is logically flawed. Here is your logic: IF ON CORRECT ACTION THEN IF FORM SUBMITTED THEN CHECK FOR HEADSHOT ERROR DISPLAY FORM END IF END IF Logically, your code says, "Display this form only if the form was submitted." So I ask you, how can you ever display the form in the first place? My gut instinct is that you have another form that posts to this page ~OR~ you have a quick hack embedded in your code to get the form to display the first time. In either case, you should post more of your code. Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/#findComment-382900 Share on other sites More sharing options...
graham23s Posted November 1, 2007 Author Share Posted November 1, 2007 sure i can post the whole lot a wee bit long but here goes: <?php ################################################### # myaccount.php # ################################################### ## Grab some basic fields from mysql $query_fields = "SELECT `profileviews` FROM `users` WHERE `id`='$var_loggedinuserid'"; $results_fields = mysql_query($query_fields) or die ("Error grabbing fields from mysql"); $row_fields = mysql_fetch_array($results_fields) or die ("Error getting array"); $var_views = $row_fields['profileviews']; echo ("<table class=\"tables_look\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td valign=\"top\">"); echo ("<table class=\"sub_table\" align=\"left\" width=\"300\" border=\"1\" bordercolor=\"#000000\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"header_boxes\" align=\"left\"><span class=\"prof_head\">Hi, $var_loggedinuser!</span> <font color=\"white\"><b>[</b></font><a href=\"profile.php?id=$var_loggedinuserid\"><font color=\"yellow\">View Profile</font></a><font color=\"white\"><b>]</b></font><font color=\"white\"><b>[</b></font><a href=\"logout.php\"><font color=\"yellow\">Logout</font></a><font color=\"white\"><b>]</b></font></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td colspan=\"2\" align=\"center\"><img src=\"uploads/70889844.jpg\" alt=\"$var_loggedinuser\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"header_boxes\" align=\"left\"><span class=\"prof_head\">Mail Options...</span></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"\">Inbox - (0)</a></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"\">Sentbox - (0)</a></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"\">Audition Offers - (0)</a></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"\">Friend Requests - (0)</a></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"header_boxes\" align=\"left\"><span class=\"prof_head\">Profile Options...</span></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=editprofile\">Edit Profile</a></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=uploadphotos\">Upload Photos</a></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=editcomments\">Edit Comments</a></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=uploadvideos\">Upload Audition Video</a></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=editresume\">Edit Resumé</a></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><a class=\"foot_links\" href=\"myaccount.php?action=settings\">Settings</a></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"header_boxes\" align=\"left\"><span class=\"prof_head\">Profile Statistics...</span></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>Profile Views</b></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>$var_views</b></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>Profile Comments</b></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>0</b></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>Uploaded Photos</b></td><td bgcolor=\"#d5e8fb\" width=\"50%\" align=\"center\"><b>0</b></td>"); echo ("</tr>"); echo ("</table>"); ## new table cell data echo ("</td>"); echo ("<td valign=\"top\" align=\"right\">"); ## google ads ?> <?php ## end html tables echo ("</td>"); echo ("</tr>"); echo ("</table>"); ## see if the get is set only display if it is if(!isset($_GET['action'])) { } else { echo ("<hr />"); ## The GET action code if($_GET['action'] == 'editprofile') { ## Grab the POST data if(isset($_POST['submit'])) { ## Grab the post data $fname = mysql_real_escape_string(trim($_POST['fname'])); $lname = mysql_real_escape_string(trim($_POST['lname'])); $month = mysql_real_escape_string(trim($_POST['month'])); $day = mysql_real_escape_string(trim($_POST['day'])); $year = mysql_real_escape_string(trim($_POST['year'])); $country = mysql_real_escape_string($_POST['country']); $gender = mysql_real_escape_string($_POST['gender']); $build = mysql_real_escape_string($_POST['build']); $hair = mysql_real_escape_string($_POST['hair']); $eyes = mysql_real_escape_string($_POST['eye']); $ethnic = mysql_real_escape_string($_POST['ethnic']); $about = mysql_real_escape_string($_POST['about']); ## Update the database $query_update = "UPDATE `users` SET `fname`='$fname',`lname`='$lname',`month`='$month',`day`='$day',`year`='$year',`country`='$country',`gender`='$gender',`build`='$build',`hair`='$hair',`eye_c`='$eyes',`ethnic`='$ethnic',`aboutme`='$about' WHERE `id`='$var_loggedinuserid'"; $results_update = mysql_query($query_update) or die ("Error updating the database!"); echo '<div style="border: 2px solid black;padding:10px; background: red; color: #ffffff; font-size: 16px;"><b>Your profile details have been updated.</b></div><br />'; } $query_user_data = "SELECT * FROM `users` WHERE `id`='$var_loggedinuserid'"; $results_user_data = mysql_query($query_user_data) or die ("Error getting the users data!"); $row = mysql_fetch_array($results_user_data) or die ("Error getting the array!"); ## The users data $var_firstname = $row['fname']; $var_lastname = $row['lname']; $var_month = $row['month']; $var_day = $row['day']; $var_year = $row['year']; $var_country = $row['country']; $var_gender = $row['gender']; $var_build = $row['build']; $var_hair = $row['hair']; $var_eye = $row['eye_c']; $var_ethnic = $row['ethnic']; $var_about = $row['aboutme']; ## Gender array $gender_array = array("M","F"); ## months list $months_list = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ## days array $days = range(1,31); ## years array $years = range(1907,2007); ## countries array $country_list = array("Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "England", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Scotland", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"); ## Arrays $feet_array = array("1","2","3","4","5","6","7","8"); $inches_array = array("1","2","3","4","5","6","7","8","9","10","11"); $eye_array = array("Black","Blue","Brown","Grey","Green","Hazel"); $stones_array = array("1","2","3","4","5","6","7","8"); $lbs_array = array("0","1","2","3","4","5","6","7","8","9","10","11","12","13"); $hair_array = array("Auburn","Black","Blonde","Brown","Grey","Red","White","Multi-Colored"); $build_array = array("Athletic","Medium","Slim","Muscular","Large"); $playages1 = array("1","2","3","4","5","6","7","8","9","10","11"); $playages2 = array("1","2","3","4","5","6","7","8","9","10","11"); $ethnic_array = array("African","African American","Asian/Pacific Islander","Caucasian","European","Hispanic","Indian","Middle Eastern","Native American","Asian","Mixed Race","Other Ethnicity"); echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>Fill in your vital statistics , the more you fill in the better chance you are of finding work.</b></div><br />'; echo ("<form action=\"myaccount.php?action=editprofile\" method=\"POST\">"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/edit_profile.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>First Name</b></td><td width=\"50%\" align=\"left\"><input type=\"text\" name=\"fname\" size=\"30\" value=\"$var_firstname\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Last Name</b></td><td width=\"50%\" align=\"left\"><input type=\"text\" name=\"lname\" size=\"30\" value=\"$var_lastname\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Date Of Birth</b></td><td width=\"50%\" align=\"left\">"); ################################################################################# echo '<select name="month">'; foreach ($months_list as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_month) { echo 'Selected'; } echo ">{$value}</option>"; } echo "</select>"; ################################################################################# ################################################################################# echo '<select name="day">'; foreach ($days as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_day) { echo 'Selected'; } echo ">{$value}</option>"; } echo "</select>"; ################################################################################# echo '<select name="year">'; foreach ($years as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_year) { echo 'Selected'; } echo ">{$value}</option>"; } echo "</select>"; ################################################################################# echo ("</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Country</b></td><td width=\"50%\" align=\"left\">"); echo ("<select name=\"country\">"); ######################################################################### foreach ($country_list as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_country) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### echo ("</select>"); echo ("</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Gender</b></td><td width=\"50%\" align=\"left\">"); ######################################################################### foreach ($gender_array as $value) { echo '<input type="radio" name="gender" id="radio_'.$value.'" value="'.$value.'" '; if ($value == $var_gender) { echo 'checked="checked"'; } echo ' /><label for="radio_'.$value.'">'.$value.'</label>'; } ######################################################################### echo ("</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Body Type</b></td><td width=\"50%\" align=\"left\"><select name=\"build\">"); ######################################################################### foreach ($build_array as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_build) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Hair Color</b></td><td width=\"50%\" align=\"left\"><select name=\"hair\">"); ######################################################################### foreach ($hair_array as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_hair) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### echo ("</select>"); echo ("</td>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Eye Color</b></td><td width=\"50%\" align=\"left\"><select name=\"eye\">"); ######################################################################### foreach ($eye_array as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_eye) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### echo ("</select>"); echo ("</td>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Ethnicity</b></td><td width=\"50%\" align=\"left\"><select name=\"ethnic\">"); ######################################################################### foreach ($ethnic_array as $value) { echo "<option Value=\"{$value}\""; if ($value == $var_ethnic) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### echo ("</tr>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\" valign=\"top\"><b>About Me</b></td><td width=\"50%\" align=\"left\"><textarea name=\"about\" rows=\"20\" cols=\"60\">$var_about</textarea></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Update Profile\"></td>"); echo ("</tr>"); echo ("</table></form>"); } if($_GET['action'] == 'uploadphotos') { if(isset($_POST['submit_2'])) { ## The vars $var_headshot = $_FILES['headshot']['name']; ## Empty submission if(empty($var_headshot)) { stderr("Upload Failed","No photo was uploaded!"); unset($_POST['submit_2']); } echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>This photo will appear on your profile as your main one.</b></div><br />'; echo ("<form action=\"myaccount.php?action=uploadphotos\" method=\"POST\" enctype=\"multipart/form-data\" />"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/edit_profile.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Upload Headshot</b></td><td width=\"50%\" align=\"left\"><input type=\"file\" name=\"headshot\" size=\"40\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit_2\" value=\"Upload Headshot\"></td>"); echo ("</tr>"); echo ("</table>"); } // End post isset } if($_GET['action'] == 'editcomments') { echo 'Edit Comments'; } if($_GET['action'] == 'uploadvideos') { echo 'Upload Videos'; } if($_GET['action'] == 'settings') { ## Grab the POST data if(isset($_POST['submit'])) { $private = mysql_real_escape_string($_POST['private']); ## Update the database $query_settings = "UPDATE `users` SET `privacy`='$private' WHERE `id`='$var_loggedinuserid'"; $results_settings = mysql_query($query_settings) or die ("Error updating the database!"); echo '<div style="border: 2px solid black;padding:10px; background: red; color: #ffffff; font-size: 16px;"><b>Your settings have been updated.</b></div><br />'; } ## Arrays $private_array = array("Everyone","Only My Friends"); $query_user = "SELECT `privacy` FROM `users` WHERE `id`='$var_loggedinuserid'"; $results_user = mysql_query($query_user) or die ("Error getting the users data!"); $rows = mysql_fetch_array($results_user) or die ("Error getting the array!"); $var_private = $rows['privacy']; echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>Set or unset the settings you like here.</b></div><br />'; echo ("<form action=\"myaccount.php?action=settings\" method=\"POST\">"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/settings.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Show Contact Telephone Number To</b></td><td width=\"50%\" align=\"left\">"); ######################################################################### foreach ($private_array as $value) { echo '<input type="radio" name="private" id="radio_'.$value.'" value="'.$value.'" '; if ($value == $var_private) { echo 'checked="checked"'; } echo ' /><label for="radio_'.$value.'">'.$value.'</label>'; } ######################################################################### echo ("</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Update Settings\"></td>"); echo ("</tr>"); echo ("</table></form>"); } } // end the isset ?> thanks mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/#findComment-382915 Share on other sites More sharing options...
roopurt18 Posted November 1, 2007 Share Posted November 1, 2007 Jesus, what a train wreck. If that code is something you inherited from someone else, then I feel your pain. If that is code you wrote yourself, then I suggest you schedule some time to learn about functions and other organizational techniques. Having more organized code makes troubleshooting it much, much easier! That said, here is what I found with your code. You have three form tags, but only two closing tags. So you forgot to close one of your forms, i.e. the one for: <form action=\"myaccount.php?action=uploadphotos\" As for the actual problem, the only way from that code that you can possibly be accessing the section of code that processes the upload photo form is by following a link on the page or by typing the url in the address. Since there's an 'Upload Photo' link on the page, I imagine you're clicking on that. Which brings us back to the point I made in my first post: Your page is coded so that the form can only be displayed if it has been submitted. You can't submit a form until it has been displayed. You've created yourself a chicken and egg problem. Do you understand what I'm saying? Here is your relevant code: if($_GET['action'] == 'uploadphotos') { if(isset($_POST['submit_2'])) { ## The vars $var_headshot = $_FILES['headshot']['name']; ## Empty submission if(empty($var_headshot)) { stderr("Upload Failed","No photo was uploaded!"); unset($_POST['submit_2']); } /** * THIS IS YOUR CODE TO DISPLAY THE FORM. HOWEVER YOU HAVE PLACED IT INSIDE * AN IF CONDITION THAT CAN ONLY BE TRUE IF THE FORM HAS BEEN SUBMITTED. * THEREFORE THIS FORM CAN NOT POSSIBLY BE DISPLAYED. */ echo '<div style="border: 1px solid black;padding:10px; background: yellow; color: #000000; font-size: 10px;"><b>This photo will appear on your profile as your main one.</b></div><br />'; echo ("<form action=\"myaccount.php?action=uploadphotos\" method=\"POST\" enctype=\"multipart/form-data\" />"); echo ("<table class=\"sub_table\" border=\"1\" bordercolor=\"#000000\" align=\"left\" width=\"600\" cellpadding=\"5\" cellspacing=\"0\">"); echo ("<tr>"); echo ("<td colspan=\"2\" class=\"edit\" align=\"left\"><img src=\"images/edit_profile.jpg\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td width=\"50%\" align=\"right\"><b>Upload Headshot</b></td><td width=\"50%\" align=\"left\"><input type=\"file\" name=\"headshot\" size=\"40\"></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=\"right\" colspan=\"2\" width=\"50%\" align=\"right\"><input type=\"submit\" name=\"submit_2\" value=\"Upload Headshot\"></td>"); echo ("</tr>"); echo ("</table>"); } // End post isset } Quote Link to comment https://forums.phpfreaks.com/topic/75635-isset-type-problem/#findComment-382934 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.