• 0

[PHP] Help trying to clear text when clicking on a link


Question

hey, so i'm playing around with PHP just to get used to it.

i was wondering if its possible to make this

page.php

(everything is being done and reported back to page.php btw)

have two options via submit button

Option 1 - Option 2

[submit] [submit]

when the option is clicked for it to clear the current data and show the new data when clicked.

so far i have this

if($opt1)

{

echo "option 1";

}

else

{

echo "option 2";

so $opt1 will clear everything and show the info in that IF statement.

dunno if i explained it clearly :huh:

Recommended Posts

  • 0

It might help to set out a structure for what you're wanting to do. E.g:

register3.php?agent => register3.php?agent&step=1 => register3.php?agent&step2

The current step (e.g. step = 1) needs to have the next step as it's action. For example:

<form method="post" action="register3.php?agent&step=2"></form>

Follow this general pattern and it should make things clearer. ;) Let me know if you need any further clarification.

Steven

  • 0
It might help to set out a structure for what you're wanting to do. E.g:

register3.php?agent => register3.php?agent&step=1 => register3.php?agent&step2

The current step (e.g. step = 1) needs to have the next step as it's action. For example:

<form method="post" action="register3.php?agent&step=2"></form>

Follow this general pattern and it should make things clearer. ;) Let me know if you need any further clarification.

Steven

judy wondering but

if i use only IF statements to create the form will all the data thats inputted in each from step be saved globally?

if not, then will a switch style form work the way i want it to work?

  • 0
judy wondering but

if i use only IF statements to create the form will all the data thats inputted in each from step be saved globally?

if not, then will a switch style form work the way i want it to work?

When you move from step to step, you'll need to re-post all the data to that step (by outputting it in the form like you did previously). You can have it remember data globally by storing it as a session or cookie. A switch statement will work the same as if statements - a switch statement is basically a more compact way of writing if statements. E.g. this set of if statements:

if($test == 4) 
{
echo 'It is 4!';
}
else if($test == 10)
{
echo 'It is 10!';
}
else
{
echo $test;
}

corresponds to this switch statement:

switch($test)
{
case 4:
echo 'It is 4!';
break;
case 10:
echo 'It is 10!';
break;
default:
echo $test;
break;
}

Steven

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.