dadoef Posted April 25, 2006 Share Posted April 25, 2006 First my code[code]include "database.php";$database=new MySQLDB();$modules=$database->getBrasam();echo "<form method=post action=usercreate.php>\n";if($_POST[modules]==""){ echo "<select name=modules>\n"; for($i=0;$i<count($modules);$i++) { echo "<option value=$modules[$i]>$modules[$i]</option>\n"; } echo "</select><br>\n";}else{ if($_POST[LT]=="" || $_POST[PORT]=="" || $_POST[vp]=="" || $_POST[vc]="") { echo $_POST[modules]."<br>"; echo "<INPUT TYPE=hidden name=modules value=$_POST[modules]>"; echo "LT:<INPUT TYPE=text NAME=LT SIZE=4>"; echo " PORT:<INPUT TYPE=text NAME=PORT SIZE=4>"; echo " VP: <INPUT TYPE=text NAME=vp SIZE=4>"; echo " VC: <INPUT TYPE=text NAME=vc SIZE=4><BR>"; } else { //echo $_POST[veecee]."<br>"; if($_POST[moduleend]=="") { echo $_POST[modules]."<br>"; echo "<INPUT TYPE=hidden name=modules value=$_POST[modules]>"; echo "<INPUT TYPE=hidden name=PORT value=$_POST[PORT]>\n"; echo "<INPUT TYPE=hidden name=LT value=$_POST[LT]>\n"; echo "<INPUT TYPE=hidden name=vp value=$_POST[vp]>\n"; echo "<INPUT TYPE=hidden name=vc value=$_POST[vc]>\n"; echo "LT= $_POST[LT] PORT= $_POST[PORT] VP= $_POST[vp] VC= $_POST[vc]<br>\n"; echo "<select name=modules>\n"; for($i=0;$i<count($modules);$i++) { echo "<option value=$modules[$i]>$modules[$i]</option>\n"; } echo "</select><br>\n"; } }}echo "<INPUT TYPE=submit VALUE=Verzenden>";echo "</form>";[/code]Now the problem I have is the following, every time I print this it doesn't echo the $_POST[vc] anymore?I can't see anything wrong with my code?Anyone has an idea? Quote Link to comment Share on other sites More sharing options...
Mortier Posted April 25, 2006 Share Posted April 25, 2006 Well I can't really understand what your script does but there's a proper way to echo HTML and variablesyou have:[code] echo "<INPUT TYPE=hidden name=vc value=$_POST[vc]>\n";[/code]try changing it into:[code] echo "<input type='hidden' name='vc' value='" . $_POST['vc'] . "'>\n";[/code]Im not sure if this will fix your problem but this way you kind of break out of the echo which is better for variabeles I believe. I've had problems with that.if it doesnt work ->Explain a bit what your code does (use comments) and what is actually done (information is inserted using a form) Quote Link to comment Share on other sites More sharing options...
dadoef Posted April 25, 2006 Author Share Posted April 25, 2006 [code] echo "<input type='hidden' name='vc' value='" . $_POST['vc'] . "'>\n";[/code]I have tried this before but this gives me the following error.[code]Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in usercreate.php on line 46[/code]I need to make a form which does a kind of refresh every page.Every step it checks if the previous form fields aren't blank, then you can go to the next step.In the next step there is a following field and it echo's the previous field. Normally, the next field can't be displayed if one of the values is blank but this one does.The weird part is, if I use get it shows the value in the addressbar usercreate.php?vc=... but if I do a $_GET[vc] it doesn't return the value.Any ideas? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 Put these two debug statements at the start of the script that proceeses the form:[code]<?phpecho '<pre> $_POST Array: ' . htmlentities(stripslashes(print_r($_POST,true))) . '</pre>';echo '<pre> $_GET Array: ' . htmlentities(stripslashes(print_r($_GET,true))) . '</pre>';?>[/code]See what is displayed on the screen and see if you can see what the problem is.Ken Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 26, 2006 Share Posted April 26, 2006 echo "<form method=post action=usercreate.php>\n";change toecho "<form method='post' action='usercreate.php'>\n";[code]include "database.php";$database=new MySQLDB();$modules=$database->getBrasam();echo "<form method='post ' action='usercreate.php'>\n";if($_POST[modules]==""){ echo "<select name='modules'>\n"; for($i=0;$i<count($modules);$i++) { echo "<option value='$modules[$i]'>$modules[$i]</option>\n"; } echo "</select><br>\n";}else{ if($_POST[LT]=="" || $_POST[PORT]=="" || $_POST[vp]=="" || $_POST[vc]="") { echo $_POST[modules]."<br>"; echo "<INPUT TYPE='hidden' name='modules' value='".$_POST[modules]."'>"; echo "LT:<INPUT TYPE='text' NAME='LT' SIZE='4'>"; echo " PORT:<INPUT TYPE='text' NAME='PORT' SIZE='4'>"; echo " VP: <INPUT TYPE='text' NAME='vp' SIZE='4'>"; echo " VC: <INPUT TYPE='text' NAME='vc'SIZE='4'><BR>"; } else { //echo $_POST[veecee]."<br>"; if($_POST[moduleend]=="") { echo "'.$_POST[modules].'"<br>";'".$_POST[LT]."'>\n"; echo "<INPUT TYPE='hidden' name='vp' value='".$_POST[vp]."'>\n"; echo "<INPUT TYPE='hidden' name='vc' value='".$_POST[vc]"'.>\n"; echo "LT= $_POST[LT] PORT= '".$_POST[PORT]."' VP= '".$_POST[vp]."' VC= '".$_POST[vc]."'<br>\n"; echo "<select name='modules'>\n"; for($i=0;$i<count($modules);$i++) { echo "<option value='".$modules[$i]."'>$modules[$i]</option>\n"; } echo "</select><br>\n"; } }}echo "<INPUT TYPE='submit' VALUE='Verzenden'>";echo "</form>";[/code] Quote Link to comment 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.