Hi. I have just started using PHP and created a form for users to select a combination of 3 products. But, I have two problems with the form.
Problem 1: the user has to submit twice to get the form to post. I view the page source and the form action is set just fine so I do not understand why the form won't submit.
Problem 2: After the form finally gets processed, if the user decides to go back to the form to add more products, the form action never gets reset to $_SERVER['PHP_SELF'].
Never mind- solved my problem!
Newbie- Problem with Submit; Please Help
Moderator: General Moderators
Newbie- Problem with Submit; Please Help
Last edited by patti on Mon Nov 14, 2005 10:02 pm, edited 1 time in total.
- blacksnday
- Forum Contributor
- Posts: 252
- Joined: Sat Jul 30, 2005 6:11 am
- Location: bfe Ohio :(
Your Form start is messed up.. change:
to
you dont need to stop the echo to use a php variable.
For a person who has dealt heavily with forms and php in the
past two months... your form code scares me!
LOL... that would be a nightmare to edit
Same for the rest of the form, you can use ONE echo for whole form and remove all the
print stuff...
edit to add:
You can also move all the
to be either all above or below form, that way the form can be purely
one echo without breaks. unless you need them there for display reasons
Not sure if this is correct, but couldnt you do something like
then in the form for the value of the field:
if that works then you could clean up the form and be way easier to debug later.
then just continue the changes for the rest of the form
Code: Select all
echo "<FORM method=\"POST\" name=\"prods\" action=\""; print $action; echo "\">";Code: Select all
echo "<FORM method=\"POST\" name=\"prods\" action=\"$action\">For a person who has dealt heavily with forms and php in the
past two months... your form code scares me!
LOL... that would be a nightmare to edit
Same for the rest of the form, you can use ONE echo for whole form and remove all the
print stuff...
edit to add:
You can also move all the
Code: Select all
if(isset($_POST['rthqty'])) print $rthqty;one echo without breaks. unless you need them there for display reasons
Not sure if this is correct, but couldnt you do something like
Code: Select all
if(isset($_POST['rthqty'])$rtest = $rthqty)Code: Select all
<td><input type=\"text\" size=\"3\" name=\"prods[product1]\" value=\"$rtest\">Code: Select all
$baseamt=$_POST['baseamt'];
if(isset($_POST['rthqty'])$rtest = $rthqty)
echo "
<FORM method=\"POST\" name=\"prods\" action=\"$action\">
<table cellspacing =\"0\" cellpadding=\"4\" border=\"3\" \>"
<tr>
<th> prods available</th>
<th> Enter the Qty.</th>
<th> Cost<br />USD</th>
<th> Discount %</th>
<th> Discount Total</th>
<th> SubTotal</th>
</tr>
<tr>
<td><input type=\"hidden\" name=\"product1\" value=\"product1\" />product1</td>
<td><input type=\"text\" size=\"3\" name=\"prods[product1]\" value=\"$rtest\">
";
Last edited by blacksnday on Mon Nov 14, 2005 6:46 pm, edited 2 times in total.
I have the action set to print right now for further testing. It doesn't seem to matter one way or another for the form to have to be submitted twice. And, yes, I have all the if(isset ...) for display reasons.
I have not been coding for months; I just started learning all of this 3 weeks ago, so I'm sure my code is not the best -
I have not been coding for months; I just started learning all of this 3 weeks ago, so I'm sure my code is not the best -