saiya Posted January 5, 2010 Share Posted January 5, 2010 hey, so i'm playing around with PHP just to get used to it. i was wondering if its possible to make this page.php (everything is being done and reported back to page.php btw) have two options via submit button Option 1 - Option 2 [submit] [submit] when the option is clicked for it to clear the current data and show the new data when clicked. so far i have this if($opt1) { echo "option 1"; } else { echo "option 2"; so $opt1 will clear everything and show the info in that IF statement. dunno if i explained it clearly :huh: Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/ Share on other sites More sharing options...
0 saiya Posted January 6, 2010 Author Share Posted January 6, 2010 well this is my live example Test Site when a person chooses either Agent or Broker, for the screen to clear and display the register script i made specific to either agent or broker. my goal really is to learn PHP and to only have 1 php page to handle all request. Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592076058 Share on other sites More sharing options...
0 smctainsh Posted January 6, 2010 Share Posted January 6, 2010 I think I understand what you want. What about having something like this? if(isset($_POST['agent'])) { // They picked the agent button include('agentform.php'); } else if(isset($_POST['broker'])) { // They picked the broker button include('brokerform.php'); } Then, you can create your agent form and broker form in the corresponding files. :) Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592076160 Share on other sites More sharing options...
0 saiya Posted January 6, 2010 Author Share Posted January 6, 2010 oh, ya i was somewhat on the right state of mind there. i thought of the isset function but not used it correctly anyhow, i applied the code. bit it still shows the selection buttons. i was wanting it to clear the entire screen and output the agent/brokerform.php all within the register3.php Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592076172 Share on other sites More sharing options...
0 smctainsh Posted January 6, 2010 Share Posted January 6, 2010 oh, ya i was somewhat on the right state of mind there. i thought of the isset function but not used it correctlyanyhow, i applied the code. bit it still shows the selection buttons. i was wanting it to clear the entire screen and output the agent/brokerform.php all within the register3.php In that case, here's what you're looking for: if(isset($_GET['agent'])) { // They picked the agent button include('agentform.php'); } else if(isset($_GET['broker'])) { // They picked the broker button include('brokerform.php'); } else { // Show the buttons } Your form needs to look like this: <form method="post" action="register3.php?agent"> <input type="submit" name="agent" value="Agent" /> </form> <form method="post" action="register3.php?broker"> <input type="submit" name="broker" value="Broker" /> </form> That way is the better way to go because the GET variables can be easily transferred via the page URL itself; not the same case for POST variables. Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592076432 Share on other sites More sharing options...
0 saiya Posted January 6, 2010 Author Share Posted January 6, 2010 wow, thank you steven... i was on the right track but i was just overthinking the entire thing making it rather complicated in my mind. you been a real big help thanks! i'm buying you a virtual beer :beer: Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592076662 Share on other sites More sharing options...
0 saiya Posted January 6, 2010 Author Share Posted January 6, 2010 hey just out of curiousity how would you have use this tehcnique to invoke a type of slides to register with. i.e. company info -- next personal info -- next logi info -- submit and all data returns to register3.php where i have all the PHP/SQL to enter all data into the database Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592077096 Share on other sites More sharing options...
0 saiya Posted January 6, 2010 Author Share Posted January 6, 2010 so this what i have so far Live test site when the user clicks on an option it takes them to the form i want. but when the 'next' button is pressed it refreshes my IF statement... i think i nested my IF statements correctly as its not giving me a blank .php page meaning that the code is being run correctly right? my logic here is this if(isset($_GET['option1'])){ echo " text"; echo "<form action='register.php?next'><input type='submit' name='next' value='Next'></form>"; if(isset($_GET['next'])){ echo "you pressed next"; } }else if(isset($_GET['option2'])){ echo " text"; }else{ echo " text"; } the code loops right when i press Next in the Option1 section and doesn't go proceed to the next section. i have all my code in the register.php and really didn't want to make other php pages for each option as I want all data to be processed by my SQL queries i have in the register.php page Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592077684 Share on other sites More sharing options...
0 smctainsh Posted January 6, 2010 Share Posted January 6, 2010 wow, thank you steven...i was on the right track but i was just overthinking the entire thing making it rather complicated in my mind. you been a real big help thanks! i'm buying you a virtual beer :beer: Not a problem! I'm very glad it helped you. :D so this what i have so farLive test site when the user clicks on an option it takes them to the form i want. but when the 'next' button is pressed it refreshes my IF statement... i think i nested my IF statements correctly as its not giving me a blank .php page meaning that the code is being run correctly right? my logic here is this if(isset($_GET['option1'])){ echo " text"; echo "<form action='register.php?next'><input type='submit' name='next' value='Next'></form>"; if(isset($_GET['next'])){ echo "you pressed next"; } }else if(isset($_GET['option2'])){ echo " text"; }else{ echo " text"; } the code loops right when i press Next in the Option1 section and doesn't go proceed to the next section. i have all my code in the register.php and really didn't want to make other php pages for each option as I want all data to be processed by my SQL queries i have in the register.php page To set up the scenario that you have in mind, you'll need to remember two things: 1) Have a $_GET variable which determines the account type - broker or agent; 2) Have a $_GET variable which determines the step. The key here is to isolate the agent form output and submission from the broker form output and submission and again isolate all of that from the introductory form. The first thing you'll need to do is set up your if statements as before: if(isset($_GET['agent'])) { // This is where we will handle all agent actions } else if(isset($_GET['broker'])) { // This is where we'll handle all broker actions } else { // This is where we'll handle all introductory form actions } Then, we'll expand on this to include the step the user is currently up to by using a switch statement: if(isset($_GET['agent'])) { switch($_GET['step']) { default: case 1: // Output the step one form right here break; case 2: // Process the step one form data here // Output the step two form here break; // And so on and so forth until all your steps are catered for. } } Do the same for broker, and you'll be able to handle all the steps. :) To use this in your forms, you'll need to have your step 1 form submit data to step 2, using the action attribute of the form tag: <form method="post" action="register3.php?agent&step=2"> <!-- My step one form goes here --> </form> And hey presto! It should all work out nicely. Let me know if any of this is at all confusing, because I get the feeling I haven't explained it in the best way... :p Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592080204 Share on other sites More sharing options...
0 saiya Posted January 7, 2010 Author Share Posted January 7, 2010 hmmm, ok so i played around with it but i think i got a little confused now. i know that you only listed the hiarchy for agent so i got that far. i plugged in what i thought you were talking about but i just ended up getting lost heh. OK, so this is what i got from your awesome explanation. if(isset($_GET['agent'])) { step 1 for agent with next button labeled 'next' } else if(isset($_GET['broker'])) { // This is where we'll handle all broker actions } else { choose agent or broker slide } then with the switched statement (where i got lost btw) if(isset($_GET['agent'])) { switch($_GET['step']) { default: case 1: // Output the step one form right here -- wouldn't this be step 2?? as that step one is initiated when agent is pressed in the first block of code? break; case 2: // Process the step one form data here // Output the step two form here this is where i input my SQL process queries? or the code that passes all data into empty strings for later processing when the submit button is pressed? break; // And so on and so forth until all your steps are catered for. } } I get the code and its logic, just that maybe my brain trying to process more than i can handle at 5am Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592082548 Share on other sites More sharing options...
0 smctainsh Posted January 8, 2010 Share Posted January 8, 2010 Haha, not a problem. :) You are absolutely right about your comment under case 1: above. When you click the agent button, the step is basically nothing, because the $_GET variable step is missing, so you'd have the button initially go to register3.php?agent, then the form on that page would post to register3.php?agent&step=1, and that would go to register3.php?agent&step=2. So, because of this, you would end up with something like this: if(isset($_GET['agent'])) { if(isset($_GET['step'])) { // $_GET['step'] exists - which step are we on? switch($_GET['step']) { case 1: default: // Here is where you handle the input received from the form at the bottom (the initial form) - MySQL queries, etc. echo '<form method="post" action="register3.php?agent&step=2"> Form goes here </form>'; break; case 2: // And again, handle the input received from the step above - MySQL queries, etc. break; // And so on and so forth... } } else { // $_GET['step'] doesn't exist, so output the first form echo '<form method="post" action="register3.php?agent&step=1"> Your form goes here... </form>'; } } It might be even more confusing if you're not sure what switch statements are - if you want an explanation of them, I would be more than happy to help you. :) Let me know how you get on. Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592086584 Share on other sites More sharing options...
0 saiya Posted January 8, 2010 Author Share Posted January 8, 2010 just wondering, but in a multi step form, i would need to start a session for the data in the fields to be stored right? just in case the user needs to go back a step and whatnot... Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592088888 Share on other sites More sharing options...
0 bolerodan Posted January 8, 2010 Share Posted January 8, 2010 You could use sessions, or you could just simply add in Hidden form fields with values from the previous form, on the next form. Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592088940 Share on other sites More sharing options...
0 saiya Posted January 8, 2010 Author Share Posted January 8, 2010 yeah, i did think about that... hmmm say that if a user clicks the back button either from the browser of the back button i provide will they be able to edit the fields and have the data dynamically update through the form so when they hit 'register' it all updates to my DB? Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592089426 Share on other sites More sharing options...
0 saiya Posted January 8, 2010 Author Share Posted January 8, 2010 watch, this is what i have and you'll see what I mean Test Site the data isn't brought over from previous steps and its boggling my mind. I did the hidden input via a foreach statement but it does.... well you'll see what i mean Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592089948 Share on other sites More sharing options...
0 smctainsh Posted January 8, 2010 Share Posted January 8, 2010 watch, this is what i have and you'll see what I meanTest Site the data isn't brought over from previous steps and its boggling my mind. I did the hidden input via a foreach statement but it does.... well you'll see what i mean Yeah, hidden form fields would be a good idea. The problem here is that your 'cumulative' form fields are outside of your form, so they aren't picked up when the form is submitted to the next step. Just move all of your inputs into the form and you should be sorted. :) Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592090670 Share on other sites More sharing options...
0 saiya Posted January 9, 2010 Author Share Posted January 9, 2010 hmm so your saying i need to have the step 1, 2, 3 fields together? Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592090848 Share on other sites More sharing options...
0 saiya Posted January 9, 2010 Author Share Posted January 9, 2010 this is my PHP code that creates my hidden fields which I have set to text just to see the script in action if ($key!="loginInfo"){ foreach ($_POST as $key => $value) { $value=htmlentities(stripslashes(strip_tags($value))); echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592091008 Share on other sites More sharing options...
0 saiya Posted January 9, 2010 Author Share Posted January 9, 2010 ack, so i fiddled around endlessly (well for a really long while now ^-^) i can't figure out how to get everything into one <form>...</form> so its all captured by the invisible fields and passed to my varibles so i can later on input them into my sql queries... *sigh* Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592091376 Share on other sites More sharing options...
0 smctainsh Posted January 9, 2010 Share Posted January 9, 2010 ack, so i fiddled around endlessly (well for a really long while now ^-^) i can't figure out how to get everything into one <form>...</form> so its all captured by the invisible fields and passed to my varibles so i can later on input them into my sql queries... *sigh* For each step, you need to have the fields for that step and the hidden fields within the form tags, otherwise the data won't get passed to the next step. Post your code here in full and I'll show you what you need to alter. :) Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592091558 Share on other sites More sharing options...
0 saiya Posted January 9, 2010 Author Share Posted January 9, 2010 Well ok, here it goes... <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='css/hp.css' rel='stylesheet' type='text/css' /> <title>Untitled Document</title> </head> <body> <table width="720px" border="1" align="center"> <tr> <td colspan ="3">Menu goes here</td> </tr> <tr> <td width="98">some text here</td> <td width="524"> <? if(isset($_POST['agentInfo'])) { if ($key!="agentInfo"){ /* $company_name = $_POST['company_name']; $company_address = $_POST['company_address']; $company_suite = $_POST['company_suite']; $company_city = $_POST['company_city']; $company_zip = $_POST['company_zip']; $company_tel = $_POST['company_tel']; $company_fax = $_POST['company_fax']; $company_web = $_POST['company_web']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 2 - Tell us about yourself</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>First Name:</td> <td><input type='text' name='first_name' id='first_name'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='last_name' id='last_name'></td> </tr> <tr> <td>Real Estate License #:</td> <td><input type='text' name='license_num' id='license_num'></td> </tr> <tr> <td>How long have you been an Agent?</td> <td><input type='text' name='exp_age' id='exp_num'></td> </tr> <tr> <td colspan='2'>Check all that apply...</td> </tr> <tr> <td colspan='2'>What are you experienced in:</td> </tr> <tr> <td> <input type='checkbox' name='exp_sales' id='exp_sales'>Sales <input type='checkbox' name='exp_sSales' id='exp_Ssales'>Short Sales <input type='checkbox' name='exp_reo' id='exp_reo'>R.E.O. <input type='checkbox' name='exp_propmngt' id='exp_propmngt'>Property Management </td> <td> <input type='checkbox' name='exp_foreclosures' id='exp_foreclosures'>Foreclosures <input type='checkbox' name='exp_lMods' id='exp_Lmods'>Loan Modifications <input type='checkbox' name='exp_bpo' id='exp_bpo'>B.P.O. <input type='checkbox' name='exp_commreal' id='exp_commreal'>Commercial Real Estate </td> <td align='center' valign='bottom'><input type='submit' name='loginInfo' value='Next'></td> </tr> </table> </form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } } }else if(isset($_POST['loginInfo'])) { if ($key!="loginInfo"){ /* $personal_first_name = $_POST['first_name']; $personal_last_name = $_POST['last_name']; $personal_license_num = $_POST['license_num']; $personal_exp_age = $_POST['exp_age']; $personal_exp_sales = $_POST['exp_sales']; $personal_exp_sSales = $_POST['exp_sSales']; $personal_exp_reo = $_POST['exp_reo']; $personal_exp_propmngt = $_POST['exp_propmngt']; $personal_exp_foreclosures = $_POST['exp_foreclosures']; $personal_exp_lMods = $_POST['exp_lMods']; $personal_exp_bpo = $_POST['exp_bpo']; $personal_exp_commreal = $_POST['exp_commreal']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 3 - Choose your login details</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'></td> </tr> <tr> <td><input type='submit' name='register' value='Register'></td> </tr> </table> </form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } } }else if(isset($_POST['register'])) { echo " <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; }else { echo" <form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td>Step 1 - Tell us about your company</td> <td align='right'>Agent Registration</td> </tr> <tr> <td colspan'4'></td> </tr> <tr> <td colspan='2'><font color='#CC0000'>*</font> Required <h2>Company Information</h2></td> </tr> <tr> <td valign='top'><span class='required'>Company name:<font color='#CC0000'>*</font></span></td> <td width='280'><input name='company_name' type='text' id='company_name' size='40' class='required'></td> </tr> <tr> <td valign='top'>Address:</td> <td><input name='company_address' type='text' id='company_address' size='40'></td> <td> Suite:</td> <td><input name='company_suite' type='text' id='company_suite' size='4'></td> </tr> <tr> <td>City:</td> <td> <input name='company_city' id='company_city'> </td> </tr> <tr> <td>Zip Code:</td> <td><input name='company_zip' id='company_zip'></td> </tr> <tr> <td>Office Phone:</td> <td><input name='company_tel' type='text' id='company_tel'></td> </tr> <tr> <td>Fax:</td> <td><input name='fax' type='text' id='fax'></td> </tr> <tr> <td valign='top'>Website</td> <td> <input name='web' type='text' class='optional defaultInvalid url'> <span class='example'>http://www.example.com</span> </td> <td colspan='2' align='center'><input type='submit' value='Next' name='agentInfo'></td> </tr> </table> </form> </td> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } ?> </tr> <tr> <td colspan="3">Copyright information</td> </tr> </table> </body> </html> Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592093192 Share on other sites More sharing options...
0 smctainsh Posted January 9, 2010 Share Posted January 9, 2010 Try this: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='css/hp.css' rel='stylesheet' type='text/css' /> <title>Untitled Document</title> </head> <body> <table width="720px" border="1" align="center"> <tr> <td colspan ="3">Menu goes here</td> </tr> <tr> <td width="98">some text here</td> <td width="524"> <? if(isset($_POST['agentInfo'])) { if ($key!="agentInfo"){ /* $company_name = $_POST['company_name']; $company_address = $_POST['company_address']; $company_suite = $_POST['company_suite']; $company_city = $_POST['company_city']; $company_zip = $_POST['company_zip']; $company_tel = $_POST['company_tel']; $company_fax = $_POST['company_fax']; $company_web = $_POST['company_web']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 2 - Tell us about yourself</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>First Name:</td> <td><input type='text' name='first_name' id='first_name'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='last_name' id='last_name'></td> </tr> <tr> <td>Real Estate License #:</td> <td><input type='text' name='license_num' id='license_num'></td> </tr> <tr> <td>How long have you been an Agent?</td> <td><input type='text' name='exp_age' id='exp_num'></td> </tr> <tr> <td colspan='2'>Check all that apply...</td> </tr> <tr> <td colspan='2'>What are you experienced in:</td> </tr> <tr> <td> <input type='checkbox' name='exp_sales' id='exp_sales'>Sales <input type='checkbox' name='exp_sSales' id='exp_Ssales'>Short Sales <input type='checkbox' name='exp_reo' id='exp_reo'>R.E.O. <input type='checkbox' name='exp_propmngt' id='exp_propmngt'>Property Management </td> <td> <input type='checkbox' name='exp_foreclosures' id='exp_foreclosures'>Foreclosures <input type='checkbox' name='exp_lMods' id='exp_Lmods'>Loan Modifications <input type='checkbox' name='exp_bpo' id='exp_bpo'>B.P.O. <input type='checkbox' name='exp_commreal' id='exp_commreal'>Commercial Real Estate </td> <td align='center' valign='bottom'><input type='submit' name='loginInfo' value='Next'></td> </tr> </table>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } echo "</form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } }else if(isset($_POST['loginInfo'])) { if ($key!="loginInfo"){ /* $personal_first_name = $_POST['first_name']; $personal_last_name = $_POST['last_name']; $personal_license_num = $_POST['license_num']; $personal_exp_age = $_POST['exp_age']; $personal_exp_sales = $_POST['exp_sales']; $personal_exp_sSales = $_POST['exp_sSales']; $personal_exp_reo = $_POST['exp_reo']; $personal_exp_propmngt = $_POST['exp_propmngt']; $personal_exp_foreclosures = $_POST['exp_foreclosures']; $personal_exp_lMods = $_POST['exp_lMods']; $personal_exp_bpo = $_POST['exp_bpo']; $personal_exp_commreal = $_POST['exp_commreal']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 3 - Choose your login details</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'></td> </tr> <tr> <td><input type='submit' name='register' value='Register'></td> </tr> </table>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } echo " </form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } }else if(isset($_POST['register'])) { echo " <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; }else { echo" <form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td>Step 1 - Tell us about your company</td> <td align='right'>Agent Registration</td> </tr> <tr> <td colspan'4'></td> </tr> <tr> <td colspan='2'><font color='#CC0000'>*</font> Required <h2>Company Information</h2></td> </tr> <tr> <td valign='top'><span class='required'>Company name:<font color='#CC0000'>*</font></span></td> <td width='280'><input name='company_name' type='text' id='company_name' size='40' class='required'></td> </tr> <tr> <td valign='top'>Address:</td> <td><input name='company_address' type='text' id='company_address' size='40'></td> <td> Suite:</td> <td><input name='company_suite' type='text' id='company_suite' size='4'></td> </tr> <tr> <td>City:</td> <td> <input name='company_city' id='company_city'> </td> </tr> <tr> <td>Zip Code:</td> <td><input name='company_zip' id='company_zip'></td> </tr> <tr> <td>Office Phone:</td> <td><input name='company_tel' type='text' id='company_tel'></td> </tr> <tr> <td>Fax:</td> <td><input name='fax' type='text' id='fax'></td> </tr> <tr> <td valign='top'>Website</td> <td> <input name='web' type='text' class='optional defaultInvalid url'> <span class='example'>http://www.example.com</span> </td> <td colspan='2' align='center'><input type='submit' value='Next' name='agentInfo'></td> </tr> </table> </form> </td> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } ?> </tr> <tr> <td colspan="3">Copyright information</td> </tr> </table> </body> </html> The key is to move the closing form tags below the foreach statements, so that they are captured by the form. Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592095360 Share on other sites More sharing options...
0 saiya Posted January 10, 2010 Author Share Posted January 10, 2010 Try this: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='css/hp.css' rel='stylesheet' type='text/css' /> <title>Untitled Document</title> </head> <body> <table width="720px" border="1" align="center"> <tr> <td colspan ="3">Menu goes here</td> </tr> <tr> <td width="98">some text here</td> <td width="524"> <? if(isset($_POST['agentInfo'])) { if ($key!="agentInfo"){ /* $company_name = $_POST['company_name']; $company_address = $_POST['company_address']; $company_suite = $_POST['company_suite']; $company_city = $_POST['company_city']; $company_zip = $_POST['company_zip']; $company_tel = $_POST['company_tel']; $company_fax = $_POST['company_fax']; $company_web = $_POST['company_web']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 2 - Tell us about yourself</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>First Name:</td> <td><input type='text' name='first_name' id='first_name'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='last_name' id='last_name'></td> </tr> <tr> <td>Real Estate License #:</td> <td><input type='text' name='license_num' id='license_num'></td> </tr> <tr> <td>How long have you been an Agent?</td> <td><input type='text' name='exp_age' id='exp_num'></td> </tr> <tr> <td colspan='2'>Check all that apply...</td> </tr> <tr> <td colspan='2'>What are you experienced in:</td> </tr> <tr> <td> <input type='checkbox' name='exp_sales' id='exp_sales'>Sales <input type='checkbox' name='exp_sSales' id='exp_Ssales'>Short Sales <input type='checkbox' name='exp_reo' id='exp_reo'>R.E.O. <input type='checkbox' name='exp_propmngt' id='exp_propmngt'>Property Management </td> <td> <input type='checkbox' name='exp_foreclosures' id='exp_foreclosures'>Foreclosures <input type='checkbox' name='exp_lMods' id='exp_Lmods'>Loan Modifications <input type='checkbox' name='exp_bpo' id='exp_bpo'>B.P.O. <input type='checkbox' name='exp_commreal' id='exp_commreal'>Commercial Real Estate </td> <td align='center' valign='bottom'><input type='submit' name='loginInfo' value='Next'></td> </tr> </table>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } echo "</form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } }else if(isset($_POST['loginInfo'])) { if ($key!="loginInfo"){ /* $personal_first_name = $_POST['first_name']; $personal_last_name = $_POST['last_name']; $personal_license_num = $_POST['license_num']; $personal_exp_age = $_POST['exp_age']; $personal_exp_sales = $_POST['exp_sales']; $personal_exp_sSales = $_POST['exp_sSales']; $personal_exp_reo = $_POST['exp_reo']; $personal_exp_propmngt = $_POST['exp_propmngt']; $personal_exp_foreclosures = $_POST['exp_foreclosures']; $personal_exp_lMods = $_POST['exp_lMods']; $personal_exp_bpo = $_POST['exp_bpo']; $personal_exp_commreal = $_POST['exp_commreal']; */ echo"<form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td colspan='2'>Step 3 - Choose your login details</td> <td align='right' colspan='2'>Agent Registration</td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'></td> </tr> <tr> <td><input type='submit' name='register' value='Register'></td> </tr> </table>"; // Loop through the POST variables passed from the previous page foreach ($_POST as $key => $value) { // Decode the POST variable $value=htmlentities(stripslashes(strip_tags($value))); // Create a hidden input containing the value echo "<input type=\"text\" name=\"" . $key . "\" value=\"" . $value . "\" />\r\n"; } echo " </form> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } }else if(isset($_POST['register'])) { echo " <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; }else { echo" <form action='".$PHPSELF."' method='POST'> <table width='524' border='0' cellpadding='3' cellspacing='3' class='forms'> <tr> <td>Step 1 - Tell us about your company</td> <td align='right'>Agent Registration</td> </tr> <tr> <td colspan'4'></td> </tr> <tr> <td colspan='2'><font color='#CC0000'>*</font> Required <h2>Company Information</h2></td> </tr> <tr> <td valign='top'><span class='required'>Company name:<font color='#CC0000'>*</font></span></td> <td width='280'><input name='company_name' type='text' id='company_name' size='40' class='required'></td> </tr> <tr> <td valign='top'>Address:</td> <td><input name='company_address' type='text' id='company_address' size='40'></td> <td> Suite:</td> <td><input name='company_suite' type='text' id='company_suite' size='4'></td> </tr> <tr> <td>City:</td> <td> <input name='company_city' id='company_city'> </td> </tr> <tr> <td>Zip Code:</td> <td><input name='company_zip' id='company_zip'></td> </tr> <tr> <td>Office Phone:</td> <td><input name='company_tel' type='text' id='company_tel'></td> </tr> <tr> <td>Fax:</td> <td><input name='fax' type='text' id='fax'></td> </tr> <tr> <td valign='top'>Website</td> <td> <input name='web' type='text' class='optional defaultInvalid url'> <span class='example'>http://www.example.com</span> </td> <td colspan='2' align='center'><input type='submit' value='Next' name='agentInfo'></td> </tr> </table> </form> </td> <td valign='bottom' align='center'> <form><input type='button' value='Back' onclick='history.go(-1)'></form> </td>"; } ?> </tr> <tr> <td colspan="3">Copyright information</td> </tr> </table> </body> </html> The key is to move the closing form tags below the foreach statements, so that they are captured by the form. Steven Oh ya! i see now, the only problem is that now it loops on step 2 and won't advance to step 3 Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592096066 Share on other sites More sharing options...
0 smctainsh Posted January 10, 2010 Share Posted January 10, 2010 From what I can see, you're echoing the variable $PHPSELF for the form action and it isn't declared anywhere. Do you mean $_SERVER['PHP_SELF']? If you do, then you'll need to change that because that'll just post the form back to itself, which will cause it to just loop, well, to itself. Steven Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592097508 Share on other sites More sharing options...
0 saiya Posted January 10, 2010 Author Share Posted January 10, 2010 yeah i meant $_SERVER['PHP_SELF'], i changed the form action back to agentform.php?agentInfo and loginInfo but i'm still looping. even tried agentform.php by itself. Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592098832 Share on other sites More sharing options...
0 saiya Posted January 13, 2010 Author Share Posted January 13, 2010 so i was able to get the script to run when its in an independant environment. but when i include it into my main page it breaks the cycle of the IF statements. i'm thinking its just as you mentioned that the $PHPSELF won't work, but now i'm wondering what i need to put in the action=' ' part in the form. Link to comment https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/#findComment-592112128 Share on other sites More sharing options...
Question
saiya
hey, so i'm playing around with PHP just to get used to it.
i was wondering if its possible to make this
page.php
(everything is being done and reported back to page.php btw)
have two options via submit button
Option 1 - Option 2
[submit] [submit]
when the option is clicked for it to clear the current data and show the new data when clicked.
so far i have this
if($opt1)
{
echo "option 1";
}
else
{
echo "option 2";
so $opt1 will clear everything and show the info in that IF statement.
dunno if i explained it clearly :huh:
Link to comment
https://www.neowin.net/forum/topic/862654-php-help-trying-to-clear-text-when-clicking-on-a-link/Share on other sites
28 answers to this question
Recommended Posts