Kaboom Posted November 29, 2009 Share Posted November 29, 2009 Okay so I am making a donation script and such to release to the VIP members of my community but for some reason I cant get it to work quite how I want... See I made it so that all the PHP is done on config.php and the everything else goes from index.php but now I need to fix the posting.. When they pick the amount they want and hit enter it takes them to the next step which is Case "2"; $option = $_POST["option"]; $message = "You picked to donate: <strong><?php echo $option ?></strong> <small><a href='index.php?step=1'>(Change)</a></small><br /> Enter your forum username: <br /> <form method='post' action='index.php?step=3'> <input autocomplete='off' type='text' name='user' title='username' name='username' class='username' value='' /><br /><br /> <input class='submit2' type='submit' value='Next Step' /></form>"; break; The first page is Case "1"; $message = "<center><strong>Select an option:</strong><br /><form method='post' action='index.php?step=2'> <select name='option' size='1'> <option value='-1'>Select an option...</option> <option value='$5 USD'>$5 USD</option> <option value='$7 USD'>$7 USD</option> <option value='$10 USD'>$10 USD</option> <option value='$15 USD'>$15 USD</option> <option value='$25 USD'>$25 USD</option> <option value='Custom'>Custom</option> </select><br /><br /><input class='submit1' type='submit' value='Next Step' /></form></center>"; break; Now I need it to take the option they picked and print it where it says you are donating this amount there but nothing is showing up. Then when they click next it has to remember that amount they picked until the very end and their username from that one and print it into the final one which is Case "3"; $message = "<b><i>Checkout Counter</i></b><br /> Forum Username: <strong><?php echo $username ?></strong><br /> Amount to Donate: <strong><?php echo $option ?></strong><br /><br /> <form method='post' action='index.php?step=4'><input class='submit2' type='submit' value='Finish' /></form><br /><br />"; break; But it doesn't show the username OR the amount and that's all I really need to get it to work, the rest is done and looks pretty awesome so .. can someone tell me what I am missing or doing wrong? I tried to add <?php $option = $_POST['option']; ?> onto page one but I get like 3 errors ... Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/ Share on other sites More sharing options...
MisterWebz Posted November 29, 2009 Share Posted November 29, 2009 Oh, nevermind. Didn't notice you tried that already. I'm not sure what the problem is here, but try this: <?php "Amount to Donate: <strong>" . $option . "</strong><br /><br />" ?> Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/#findComment-967636 Share on other sites More sharing options...
Kaboom Posted November 29, 2009 Author Share Posted November 29, 2009 <?php "Amount to Donate: <strong>" . $option . "</strong><br /><br />" ?> Well the reason that won't work is because I have it like switch($_GET['step']) { Case "2"; $option = $_POST["option"]; $message = "You picked to donate: <strong><?php echo $option ?></strong> <small><a href='index.php?step=1'>(Change)</a></small><br /> Enter your forum username: <br /> <form method='post' action='index.php?step=3'> <input autocomplete='off' type='text' name='user' title='username' name='username' class='username' value='' /><br /><br /> <input class='submit2' type='submit' value='Next Step' /></form>"; break; Default; break; } and index.php has <?php echo "$message"; ?> Where I want it to print the message strng stuff So its a PHP code INSIDE a php code and then I get encase errors or something and whatever else and it's really confusing.. I jus don't know why its not saving the posted data here's a screenshot http://www.gaming-geeks.net/sig/paypal.png Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/#findComment-967642 Share on other sites More sharing options...
KevinM1 Posted November 29, 2009 Share Posted November 29, 2009 First, your switch statement is messed up. A semicolon is used to end a statement. You do not want to use that in your cases. So, instead of: case "2"; You need to use a colon case "2": Second, since you're using PHP to generate your output, you don't need to toss in the PHP tags in order to output the value of a variable. In fact, that can cause issues with PHP thinking you're actually ending the code block when you try closing that nested tag. You should simply have: $message = "You chose to donate <strong>$option</strong>..."; Third, for step three, you need to retain the value the user specified in step 1. PHP doesn't automatically remember form values. You have two options: 1. Store the value in a hidden field in the form you create in step 2. 2. Use sessions. Option 1 is the simplest. Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/#findComment-967645 Share on other sites More sharing options...
Kaboom Posted November 29, 2009 Author Share Posted November 29, 2009 First, your switch statement is messed up. A semicolon is used to end a statement. You do not want to use that in your cases. So, instead of: case "2"; You need to use a colon case "2": 1. Store the value in a hidden field in the form you create in step 2. 2. Use sessions. Option 1 is the simplest. It works useing my cases like that and thanks for step 2 and how to I do the hidden value? Like: <input type="hidden" name="option" value="<?php echo $option ?>" /> right? Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/#findComment-967646 Share on other sites More sharing options...
KevinM1 Posted November 29, 2009 Share Posted November 29, 2009 First, your switch statement is messed up. A semicolon is used to end a statement. You do not want to use that in your cases. So, instead of: case "2"; You need to use a colon case "2": 1. Store the value in a hidden field in the form you create in step 2. 2. Use sessions. Option 1 is the simplest. It works useing my cases like that and thanks for step 2 and how to I do the hidden value? Like: <input type="hidden" name="option" value="<?php echo $option ?>" /> right? Yes, but again, since you're generating the form via PHP, you don't need to use PHP tags there. In fact, it's a bad idea. Use simply: $message .= "<input type=\"hidden\" name=\"option\" value=\"$option\" />"; Quote Link to comment https://forums.phpfreaks.com/topic/183319-well-idk-whats-wrong/#findComment-967648 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.