Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

what script do I run on a form?

form php

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1 kxx4

kxx4

    CC Newcomer

  • Member
  • PipPip
  • 24 posts

Posted 12 May 2014 - 04:08 AM

I am doing an script to enable site visitors " register" either as individual or group category.

The database is expected to load any of the form when the user selects any of the category.

 

What action script is required to make the database load the required form?

 

<form>
Select Your Category:
<SELECT NAME="category" LABEL="Select">
<OPTION VALUE="individual">Individual
<OPTION VALUE="corporate">Corporate/Group
</SELECT>
</form>



#2 Sundance

Sundance

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 572 posts

Posted 12 May 2014 - 05:27 AM

Some PHP or jQuery with an if statement.


Please read the

FaQ & Guidelines


#3 kxx4

kxx4

    CC Newcomer

  • Member
  • PipPip
  • 24 posts

Posted 13 May 2014 - 03:04 AM

I really need assistance with that code



#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 13 May 2014 - 04:17 AM

The standard question will be: what do you have so far?


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 kxx4

kxx4

    CC Newcomer

  • Member
  • PipPip
  • 24 posts

Posted 13 May 2014 - 06:16 AM

I tried this funny stuff as a learner and I need corrections to make it work:

 

<?php

if( $category = individual )
{
    
header"individualform.php");
}
else
{
    
header"groupform.php");
}


?>


 


#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 13 May 2014 - 06:39 AM

First task: you need to learn how to use the post and get variables to get form data.

 

http://www.tizag.com/phpT/postget.php


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 14 May 2014 - 09:15 PM

What you intend to do, you can do in the very HTML page, on the button click event of the form, dictating the form action to the page you want them to.

In both, PHP or Javascript, individual would be a string, ergo, enclosed like this: "individual"



#8 kxx4

kxx4

    CC Newcomer

  • Member
  • PipPip
  • 24 posts

Posted 19 May 2014 - 04:27 AM

I tried another code but it didnt not run or show any error report:

 

'  <?
 $optiona= FORM VALUE ['individual'];
 $optionb=FORM VALUE['corporate'];
 if ($optiona):
    echo {$redirect = "useraccount.php";
    if ($optionb) :
      echo {$redirect = "phptut/login.php";
    }
 else:
    echo "Please Select a Category";
 endif;
 ?>
 <form action= "select.php" method="post">
 Select Your Category:
 <SELECT NAME="category" LABEL="Select">
 <OPTION VALUE="Click to Select">Click to Select
 <OPTION VALUE="individual">Individual
 <OPTION VALUE="corporate">Corporate/Group
 </SELECT>
 <input name="add" type="submit" id="add" value="Continue to Apply">
 </form> '



#9 hard1010lad

hard1010lad

    CC Lurker

  • New Member
  • Pip
  • 4 posts

Posted 22 May 2014 - 06:06 PM

You might need something like this:

<?php//do not forget to include the html tags that should open and close your code e.g.<html><head><title></title><body></body></html>
 $optiona= "individual";
 $optionb= "corporate";
		if($_POST['category']==$optiona){
			$redirect = "useraccount.php";
			echo "<a href='.$redirect.'>Click Here to Login</a>";
		}
		if($_POST['name_of_your_select_box']==$optiona){
			$redirect = "phptut/login.php";
			echo "<a href='.$redirect.'>Click Here to Login</a>";

			else{
			echo "<p>Please Select a Category</p>";
			}
		}

 ?>
 
<form action="select.php" method="post" enctype="multipart/form-data">
 <p>Select Your Category:&nbsp;
 <select name="category"><option value="individual" selected>Individual</option>
						<option value="corporate" selected>Corporate</option>
						</select></p>

 <input name="add" type="submit" id="add" value="Continue to Apply">
</form>


#10 kxx4

kxx4

    CC Newcomer

  • Member
  • PipPip
  • 24 posts

Posted 20 June 2014 - 05:31 AM

 

You might need something like this:

<?php//do not forget to include the html tags that should open and close your code e.g.<html><head><title></title><body></body></html>
 $optiona= "individual";
 $optionb= "corporate";
		if($_POST['category']==$optiona){
			$redirect = "useraccount.php";
			echo "<a href='.$redirect.'>Click Here to Login</a>";
		}
		if($_POST['name_of_your_select_box']==$optiona){
			$redirect = "phptut/login.php";
			echo "<a href='.$redirect.'>Click Here to Login</a>";

			else{
			echo "<p>Please Select a Category</p>";
			}
		}

 ?>
 
<form action="select.php" method="post" enctype="multipart/form-data">
 <p>Select Your Category:&nbsp;
 <select name="category"><option value="individual" selected>Individual</option>
						<option value="corporate" selected>Corporate</option>
						</select></p>

 <input name="add" type="submit" id="add" value="Continue to Apply">
</form>

Thanks it helped me to solve the challenge.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download