Jump to content


Photo

Problem with form


  • Please log in to reply
4 replies to this topic

#1 dadoef

dadoef
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 April 2006 - 04:41 PM

First my 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>";
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?

#2 Mortier

Mortier
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 25 April 2006 - 06:11 PM

Well I can't really understand what your script does but there's a proper way to echo HTML and variables

you have:
 echo "<INPUT TYPE=hidden name=vc value=$_POST[vc]>\n";

try changing it into:

 echo "<input type='hidden' name='vc' value='" . $_POST['vc'] . "'>\n";

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)

#3 dadoef

dadoef
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 April 2006 - 09:15 PM

echo "<input type='hidden' name='vc' value='" . $_POST['vc'] . "'>\n";
I have tried this before but this gives me the following error.
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
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?

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 25 April 2006 - 11:27 PM

Put these two debug statements at the start of the script that proceeses the form:
<?php
echo '<pre> $_POST Array: ' . htmlentities(stripslashes(print_r($_POST,true))) . '</pre>';
echo '<pre> $_GET Array: ' . htmlentities(stripslashes(print_r($_GET,true))) . '</pre>';
?>

See what is displayed on the screen and see if you can see what the problem is.

Ken


#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 April 2006 - 03:22 AM

echo "<form method=post action=usercreate.php>\n";

change to

echo "<form method='post' action='usercreate.php'>\n";


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>";

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users