Accurax Posted December 23, 2008 Share Posted December 23, 2008 Hi chaps... Ok i have the following form... which self submits when a user selects one of the many radio buttons. <?php if(isset($_POST['myform'])){ echo "form submitted"; } echo "<form method='post' action='" . $self . "'>"; echo "<input type=radio name='myform' value='" . $row['title'] . "' onchange='this.form.submit();'>"; echo "</form>"; ?> I need to get this submitted form value into a session somehow.... but at the moment i cant seem to make the page accept the form was submitted. I was hoping someone may be able to point me in the right direction to gettng this working? ... i think it may have something to do with the way the page is processed ie.. php on the server JS on the client.... its a strange old problem ... any and all advice seriously appreciate d!! Accy Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/ Share on other sites More sharing options...
revraz Posted December 23, 2008 Share Posted December 23, 2008 Just use action='' Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722486 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 excuse me? .... could you elaborate a little please? Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722492 Share on other sites More sharing options...
revraz Posted December 23, 2008 Share Posted December 23, 2008 If you omit the action, it goes to itself. Right now, your $self is not defined so it goes no where. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722501 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 Hmmm ... that doesnt seem to help my friend.... <?php if(isset($_POST['myform'])){ echo "form submitted"; } echo "<form method='post'>"; echo "<input type=radio name='myform' value='" . $row['title'] . "' onchange='this.form.submit();'>"; echo "</form>"; ?> Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722505 Share on other sites More sharing options...
Mikedean Posted December 23, 2008 Share Posted December 23, 2008 If $self isn't being set then it would already be doing that. I'm wondering if the form is actually submitting at all, you might want to try changing the 'onchange' to 'onClick'. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722508 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 If $self isn't being set then it would already be doing that. I'm wondering if the form is actually submitting at all, you might want to try changing the 'onchange' to 'onClick'. Doesnt seem to make any difference.... the form looks like its submitting... the page refreshes, but my conditional never seems to hold true .... Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722545 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 Here's some code that works correctly... tyhere are clear differences, but maybe someone will spot something i've missed <?php if(isset($_POST['myform'])){ echo "waaaahey"; } ?> <form method="post"> <input type=radio name='myform' value='test' onchange='this.form.submit()'> </form> As you can see when the form and onChange even are outside of the php then it works correctly..... problem is i need to produce my radio buttons via a while loop, so that isnt an option Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722550 Share on other sites More sharing options...
revraz Posted December 23, 2008 Share Posted December 23, 2008 You can create the radios outside of PHP in a while loop. Just end it and restart it. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722555 Share on other sites More sharing options...
Mikedean Posted December 23, 2008 Share Posted December 23, 2008 Was '$row['title']' being set before? It might not have been setting correctly, or believing it was set correctly as it didn't have a value. That's the only difference I can see which could have caused a problem. Although saying that, I ran your original code on my localhost and it worked fine. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722557 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 $row['title'] gets set just before the form starts heres the complete code... including the loop im using: <?php $id = $_SESSION['customer_id']; $query = "SELECT * FROM mytable WHERE customers_id='$id'"; $result = mysql_query($query) or die ("could not find name"); echo "<table id=\"pres_box\" cellpadding=\"0\" cellmargin=\"0\">"; echo "<form method='post' action='" . $self . "'>"; echo "<tr>"; echo "<td colspan=\"2\" class=\"title\">"; echo "Select your option"; echo "</td>"; echo "</tr>"; while ($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; echo $row['title']; echo "</td>"; echo "<td>"; echo "<input type=radio name='myform' value='" . $row['title'] . "' onChange='this.form.submit();'>"; echo "</td>"; echo "</tr>"; } echo "</form>"; echo "</table>"; ?> how would i go about ending and restarting the while loop... as you can see i need a radio button for each entry in the database... this could be anything from 1 - 100 Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722564 Share on other sites More sharing options...
Mikedean Posted December 23, 2008 Share Posted December 23, 2008 Ah ok . while ($row=mysql_fetch_array($result)) { ?> <tr> <td> <?php echo $row['title']; ?> </td> <td> <input type='radio' name='myform' value='<?php echo $row['title'] ?>' onChange='this.form.submit();'> </td> </tr> <?php } Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722567 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 this shouldnt be this difficult surley .... its still doesnt work.... heres the conditional imusing to check if the form is submitted: <?php if(isset($_POST['prescription'])){ echo "waaaahey"; } ?> ive tried this before and after the while loop and to no avail... i just dont know whats wrong sorry to keep pestering but i really am stumped Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722578 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 Anyone else able to help with this ?? Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722625 Share on other sites More sharing options...
Accurax Posted December 23, 2008 Author Share Posted December 23, 2008 bump... could really do with some more input on this if anypne has a few moments to spare thanks in advance Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722767 Share on other sites More sharing options...
Goldeneye Posted December 23, 2008 Share Posted December 23, 2008 Why don't you try using a Submit-Button instead of a Radio-Button to submit the form? Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-722779 Share on other sites More sharing options...
Accurax Posted December 24, 2008 Author Share Posted December 24, 2008 i ant im afraid ..... this needs to happen automatically .... looks like i may have to figure it out myself.... really appreciate the help though guys Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-723088 Share on other sites More sharing options...
Razesdark Posted December 24, 2008 Share Posted December 24, 2008 What do you see when you look at the plain HTML source code when you view the actual page. And what do you see when you see when you put in print_r($POST); in your code ? This outputs everything which is inside $POST. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-723138 Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 Ask in the Javascript help forum, since that's what you are using. Link to comment https://forums.phpfreaks.com/topic/138193-self-submitting-a-form-pass-it-to-a-session-any-ideas/#findComment-723148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.