0

Hi all,

I am making a form in which i have many fields. Let me explain:

In this form there are two radio button and one field for email text box and another field for name text box.

Now i want that if i will select first radio button from my form and after filling all fields this should go like index.php page. At other case , if i will select second radio button and after filling all fields then this will go another php page like submit.php page.

How i can do this if i will click different radio button and different action should be performed.
Please help me to solve this. I will be thankful to him. This is very necessary for me.
Thanks,
Gagan

2
Contributors
5
Replies
7
Views
8 Years
Discussion Span
Last Post by ryuslash
0

You could do it server-side or client-side, I guess.

For server side you make sure that the radio buttons' value is submitted to the server and then check which was selected there (like

something.html:
<form method="POST" action="handle.php">
  <!-- your form here -->
</form>

handle.php:
if ($_POST["radiobuttongroupname"] == "something")
  header("Location: index.php");
else
  header("Location: another.php");

).

Or for client side you use the onsubmit event of the form to check which was selected (something like

<script>
  function handleSubmit(form) {
    if (form.radiobuttongroupname.value == "something")
      form.action = "index.php";
    else
      form.action = "another.php";
  }
</script>

<form method="POST" onsubmit="handleSubmit(this)">
  <!-- your form -->
</form>

)

0

thanks for reply,

but here is some another problem is coming ........

when i am submitting a form with already checked radio button then this is inserting values in database but when i do checked another radio button then this will not insert value in database.

Second problem is that this is giving error header already sent when i am using header("Location:index.php") statement.

So this problem have not solved till now. Pls help me to solve this.
thanks

0

when i am submitting a form with already checked radio button then this is inserting values in database but when i do checked another radio button then this will not insert value in database.

Ehh, I have no idea what you are trying to say...
Is it that one page does something that the other doesn't, but both really should (you could move this part to the handle.php)

Second problem is that this is giving error header already sent when i am using header("Location:index.php") statement.

the header() function is one that seems to cause a lot of confusion for a lot of people. You can only use it before any other headers have been sent (headers are sent as soon as an echo or print or any other output statement is executed)

If these tips don't help at all then I don't think I can help much more without at least your error messages or some code that produces the error...

0

thanks for so much co-operating,
But i solved this problem now.
After all i have to use this code on place of header in php. I have used javascript code this: window.location.href="which location i want to go"; now my problem have solved. Thanks friend.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.