jimfog Posted March 14, 2013 Share Posted March 14, 2013 I have a page where is s form divided on separate sections depending on the data required(name data, address data etc.) Each section can be edited individually(by clicking the appropriate icon)-like the "edit profile" page of facebook. The problem is that I cannot make the logic work correctly. For example: When one section is opened for editing and another one is already open, and I co to close the former, the second also closes something I do not want of course. Here is some code, with 2 sections(name and address): <fieldset class="basics"> <h2>Name</h2> $personal = get_personal_db($_SESSION['valid_user']); if(isset($_GET['form'])&&(isset($personal))||(isset($_GET['cancelpersonal'])))//$cancelpersonal is when the cance button is clicked and GET['form'] is the URL that leads to the form ....profile?form.php { echo $personal['name'] . '<br>' . $personal['lastname'] . '<br>' .//here data already in the db are echoed to the browser, $personal['btype'] . '<br>'; } elseif ((isset($_GET['editpersonal'])) || (!isset($_GET['cancelpersonal']))) { ?> <label class="label" for="name">*</label> <input id="name" size="40" placeholder="Όνομα" type="text" name="name"><br> <label class="label" for="lastname">*</label> <input id="lastname" size="40" placeholder="Επώνυμο" type="text" name="lastname"><br> <label class="label" for="businesstype">*</label> <input id="lastname" size="40" placeholder="Τύπος Επιχείρησης" type="text" name="businesstype"><br> <input value="Save" name="save" type="submit" id="savebutton"> <a href="http://localhost/Appointments/Administrator/profile.php?cancelpersonal" class="cancelbton">Aκύρωση</a> <?php;}</fieldset> <fieldset class="basics"> <h2>Address</h2> <a href="http://localhost/Appointments/Administrator/profile.php?editaddress" ><div class="edit"> <img src="Images/editpen.png"></a> </div> <?php $address=get_address($_SESSION['valid_user']); if((isset($_GET['form']))&&($address)||(isset($_GET['canceladress']))) { echo $address['address'].'<br>'.//εδω τυπώνονται τα στοιχεία που βρέθηκαν στην βάση $address['city'].'<br>'. $address['municipality'].'<br>'; } elseif((isset($_GET['editaddress']))||(!isset($_GET['canceladress']))) {?> <label class="label" for="address">*</label><input id="address" size="40" placeholder="Διεύθυνση" type="text" name="address"><br> <label class="label" for="city">*</label><input size="40" placeholder="Πόλη" type="text" name="city"><br> <label class="label" for="municipality">*</label><input size="40" placeholder="Νομός" type="text" name="municipality"><br> <h3>Web address</h3> <!-- <label class="label" for="wwwaddress">*</label>--> <input size="40" id="<?php if(isset($errorclass['wwwaddress'])){if($errorclass['wwwaddress']==true){echo 'wwwaddress_error';}else{echo 'wwwaddress';}}?>" placeholder="wwwaddress" type="text" name="wwwaddress"><br> <a href="http://localhost/Appointments/Administrator/profile.php?canceladress" class="cancelbton">Aκύρωση</a> <?php } If you need more code I will post.The aim is to close or open the sections individually and not the opening/closing of one affects the other Link to comment Share on other sites More sharing options...
justsomeguy Posted March 14, 2013 Share Posted March 14, 2013 If you're talking about this: elseif ((isset($_GET['editpersonal'])) || (!isset($_GET['cancelpersonal']))) just look at what it says. It's going to display that part if $_GET['editpersonal'] is set, or if $_GET['cancelpersonal'] is not set. It will not display that if both $_GET['editpersonal'] is not set, and if $_GET['cancelpersonal'] is set. So if that's not being displayed, and you think it should be, then you can either set the one variable or not set the other. Link to comment Share on other sites More sharing options...
jimfog Posted March 14, 2013 Author Share Posted March 14, 2013 I will be more specific.The problem is that if I click the edit button in the first section BOTH sections will open, something undesirable of course.Take a look at the image with the problem:https://skydrive.live.com/redir?resid=BE27434B2AAC8130!251&authkey=!ABoKLygksdiKYSc If I do what you propose:isset(editpersonal) the problem is the same in addition that when I click to edit the second section the first section closes(something which must not happen if it is open from before)-image:https://skydrive.live.com/redir?resid=BE27434B2AAC8130!252&authkey=!AM2dsUfpwx6cUqs Link to comment Share on other sites More sharing options...
justsomeguy Posted March 14, 2013 Share Posted March 14, 2013 If this is an example of the edit link: <a href="http://localhost/Appointments/Administrator/profile.php?editaddress" > Then let's see what that does. Here's one if statement, to show the address form: elseif((isset($_GET['editaddress']))||(!isset($_GET['canceladress']))) So it's going to show that because $_GET['editaddress'] is set, like it's checking for. Here's the other if statement: elseif ((isset($_GET['editpersonal'])) || (!isset($_GET['cancelpersonal']))) So it's going to show that also, because $_GET['cancelpersonal'] is not set, and you're telling it to show the form if that is not set. In fact, it's always going to show both forms unless one or both of the cancel variables are set. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now