Jump to content

[SOLVED] Live Form Updates


imperium2335

Recommended Posts

  • 1 month later...

Die causes half the page not to load :(

 

i have this:

 

<form action="<?$_SERVER['PHP_SELF']?>" method="get">

<div id="uploadbox">

<div id="number"><img src="site-images/1.jpg" /></div>

<p class="heading">Cake Details</p>

<div id="names">

<p><span class="required">Name:</span></p>

<p><span class="required">Tags:</span></p>

</div>

<div id="uploadfields">

<? 	
if($cakename == NULL && $_SESSION['timeload'] != 1)
{
    echo '<input name="cakename" type="text" class="mupinv" value="Name of the cake" />' ;
}
    else
    {
    echo '<input name="cakename" type="text" class="mup" value="Name of the cake" />' ;
    }
    ?>

 

Now the problem is that if a field isnt filled in everything is erased in the boxes when the user presses submit.

 

Is there anyway to get the page to remember what they put in without wiping the fields if they have got one wrong?

 

$_SESSION['timeload'] != 1 is to make all the boxes not red when the page first loads up.

 

Thanks in advance.

Die causes half the page not to load :(

 

When you call die() that means to stop executing at that point.

 

<form action="<?$_SERVER['PHP_SELF']?>" method="get">

 

You can also do <form action="" method="get"> or <form action="" method="post">.

 

<?

if($cakename == NULL && $_SESSION['timeload'] != 1)

{

    echo '<input name="cakename" type="text" class="mupinv" value="Name of the cake" />' ;

}

    else

    {

    echo '<input name="cakename" type="text" class="mup" value="Name of the cake" />' ;

    }

    ?>[/code]

 

Now the problem is that if a field isnt filled in everything is erased in the boxes when the user presses submit.

 

Is there anyway to get the page to remember what they put in without wiping the fields if they have got one wrong?

 

$_SESSION['timeload'] != 1 is to make all the boxes not red when the page first loads up.

 

Thanks in advance.

 

Try this:

 

echo '<input name="cakename" type="text" class="';
if($cakename == NULL && $_SESSION['timeload'] != 1) {
echo 'mupinv';
} else {
echo 'mup';
}
echo '" value="';
if ($_GET[cakename] != "") {
echo $_GET[cakename];
} else {
echo 'Name of the cake';
}
echo '" />';

 

If you use method="post", then it would be $_POST[cakename]. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.