Jump to content

[SOLVED] Live Form Updates


imperium2335

Recommended Posts

Make a sumbit button with boxes and the such, self echo the page your own when pressed, and then when the button is submitted, you code it so each box, in this case would lets say $var is one box. Then check if ( $var == "" ) if so, echo whatever you want, then die();.

Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

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]. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.