phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 So far what i have up top session_start(); if(isset($_SESSION['view'])){ if($_SESSION['view'] == 1){ exit("Host already registered!"); } } MIDDLE is the FORM code BOTTOm is where i am not sure what you mean ? i have tried this but not sure unset($_SESSION['view']); how do i know if this will work without submitting the form just yet? Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244798 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 everytime i hit refresh does nothing i tried removing history off browser displays the same info.... Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244802 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 So far what i have up top session_start(); if(isset($_SESSION['view'])){ if($_SESSION['view'] == 1){ exit("Host already registered!"); } } MIDDLE is the FORM code BOTTOm is where i am not sure what you mean ? i have tried this but not sure unset($_SESSION['view']); how do i know if this will work without submitting the form just yet? why are you unsetting the session value, that the opposite of what you would want to do.. at the bottom belongs.. $_SESSION['view'] = 1; Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244803 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 my goodness you are on fire i thought you need to clear it out first or unset the varibale/values. Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244807 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 my goodness you are on fire i thought you need to clear it out first or unset the varibale/values. nooo, basically what we are doing here is...the first time that a user clicks the link, there will not be a session that is set, so the code runs as normal...then at the end of execution we set a session to 1.. then the next time that the user would try to click on the page, they would get the error since the session is set Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244815 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 yes and no, ok whats happening is if the user does not remove the email keeps it for a while, that user still sees the values of the array, howerver as soon as i hit the refresh i get the message. (already registered) would it be better to not to see the parameter everytime they may click on an older email? i tried redirecting them to another page to clear up the url with header("Location: index.php"); doesnt work though Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244819 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 you could redirect them yes, why wouldn't it work for you here? you would only need to change one line.. session_start(); if(isset($_SESSION['test'])){ if($_SESSION['test'] == 1){ header("Location: index.php"); } } now when you refresh the page it should redirect you to the index page Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244825 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 Thanks Aykay, Now how do i start using or inserting the values into the db based on the Host from the array i have passed into reg.php? i plan on using radio buttons combo boxes and text boxes. just to start me off thanks. Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244833 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 is reg.php the target page that the array is sent to? Still not sure what you are trying to do, or how a form would have any relevance here.. but what you can do is display a form for each value in the array like so.. foreach($array as $value){ print "<form action='#' method='POST'> $value Active = <input type='radio' name='active' value='Yes' /><input type='radio' name='active' value='No' /><br /> Lease for Another 90 Days? <input type='radio' name='lease' value='Yes' /><input type='radio' name='lease' value='No' /><br /> Description <textarea name='description' cols='5' rows='30'></textarea> <input type='submit' name='$value' value='Submit' />"; } something like that perhaps, then you can grab the data based on which Host it is if(isset($_POST['Host1'])){ //if the submit button for Host1 has been pressed // sanitize data, insert into database }elseif(isset($_POST['Host2'])){ // is the submit button for Host2 has been pressed, etc... } did you see this post earlier...I addressed this Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244835 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 no i did not see that in the earlier post; but thanks aykay, what if you dont know the # of host to put in, shouldnt it be onw giant sql insert at the end ? is reg.php the target page that the array is sent to? YES I am thinking, what if the user made a mistake in submitting form and wants to click the back button he will get the redirect page right? Anyway around this problem? suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244854 Share on other sites More sharing options...
phpme1221 Posted July 19, 2011 Author Share Posted July 19, 2011 AyKay, After a user submitts the form, how do i end that session basically? i dont want to use the below code , causes too many confusion with browser staying up and not clearing cache. session_start(); if(isset($_SESSION['view'])){ if($_SESSION['view'] == 1){ //exit("Host already registered!"); header("Location: index.php"); $_SESSION['view'] = 1; The user shuoud be able to view his hosts but unable to resubmit prompting an error message. Before the user submits the user can view as many times his list of host, but as soon as the user hits submit he/she is not longer able to resubmit even from old emails? i have created a field in mysql db, Register (yes or no) so if you hits submit then it is registered if he has not it is consider a NO not registered. Therefore once he/she hits the submit, he or she is registered so how do i check everytime when the use hits submit if the parameter register is yes or no for that user? Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1244869 Share on other sites More sharing options...
phpme1221 Posted July 20, 2011 Author Share Posted July 20, 2011 Hi Aykay, Can you help me out once again, im trying to do a drop down instead of haveing the user see all the fields to enter, i want to show only 1 set of fieds with a drop down of host to choose from to enter registration, can you help me out, please I have a so far gathered from the web but its confusing Reg.php //function dropdown function generateSelect($name = '', $VM = array()) { $html = '<select name="'.$name.'">'; foreach ($VM as $value) { $html .= '<option value='.$value.'>'.$VM.'</option>'; } $html .= '</select>'; return $html; } $html = generateSelect('VM', $value); <select name="Host"> <option value="0">Choose a server</option> <?php showOptionsDrop($VM, null, true); ?> </select> HELP! Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245264 Share on other sites More sharing options...
AyKay47 Posted July 20, 2011 Share Posted July 20, 2011 so you want it to be a drop-down list instead of radio buttons? try this.. print "<select name='selections'>"; foreach($array as $value){ print "<option value='$value'>$value</option>"; } print "</select>"; which is pretty much what you have, just a little different...what exactly are you having issues with here? Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245284 Share on other sites More sharing options...
phpme1221 Posted July 20, 2011 Author Share Posted July 20, 2011 Thank Aykay coming to the rescue, I want the user to register there servers. they will be sent an email and then they click on email with there server info with identification, which leads me to the next questions how do or if i could add another array or variable in same url their email address for identiification? After they click on email they will be presented with a form to fill in their Server info to lease or use another 90 days. What do you think is the easier of the 2 ways, a drop down or show the # of forms to fill in that corralates with the number of host from array? if they dont respond within 1 week i will resend email, and on the 2nd week from the day i send out i will shutdown server. I can schedule that part. Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245309 Share on other sites More sharing options...
phpme1221 Posted July 20, 2011 Author Share Posted July 20, 2011 ok i have figure out how to pass the 2nd array or variable, done. sweet Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245335 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 Hi Aykay, Now how to i have only 1 submit for multiple hosts? I changed it to one submit instead everytime a user have to hit the submit button. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245450 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 Hi Aykay, Can you help me out once more, please how do i submit the multiple form with the different host? Here is what the form looks like [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245774 Share on other sites More sharing options...
AyKay47 Posted July 21, 2011 Share Posted July 21, 2011 i'm not exactly sure what you are asking here, are you asking how to get it to work if someone wants more then one host? can you give a quick example Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245823 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 i just want each individual owner of the server to register their server/s in the link they each get in the email. I have show how the link looks like in the previous post, it will show each of the server they own and now they have to just register it by filling in the forms, either i have 1 submit button for all forms but that seems way too difficult for me OR have multiple submit buttons for each servers they need to regiseter (own) , remember a user may only need to register 1 server ( own 1 server ) hope that explains it much simpler than it sounds and to code THANKS AYKAY Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245830 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 the problem now with multiple submits button based on the # of servers a user needs to register ( in the array ) how do you submit each form without refreshing the page? Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245833 Share on other sites More sharing options...
AyKay47 Posted July 21, 2011 Share Posted July 21, 2011 okay I see what you are saying, what I would do is have one submit button that grabs all of the data, have conditions set (if/else statements) set for each individual form....if no data is grabbed from a specific form, don't do anything with that form, if data is grabbed from a form, store that specific data in your database. Now if you decide to use a submit button for each form and don't want the page to refresh after the user submits...which is understandable, you can use either AJAX or jquery to submit the form, handle the data on the server, and output a response without refreshing the page...so that's an option here Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245843 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 okay sounds easier with 1 submit button, now can you start me off with my example? please please Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245847 Share on other sites More sharing options...
AyKay47 Posted July 21, 2011 Share Posted July 21, 2011 I do not have time right now to write a custom function since I am at work... but here's a link to start you out http://www.webmasterworld.com/forum91/1863.htm also, google something like 'multiple forms one submit button' or something along the lines of that Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245850 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 i will wait Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245866 Share on other sites More sharing options...
phpme1221 Posted July 21, 2011 Author Share Posted July 21, 2011 there have been soo many different response not sure which one to go with, use button intead fo submit , use a function use js use ajax, well i dont know enough of either gosh please help aykay Quote Link to comment https://forums.phpfreaks.com/topic/242331-passing-array-in-url/page/2/#findComment-1245891 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.