Jump to content

select different forms script


ardyandkari

Recommended Posts

hey,

 

i am making a script where you click a button and it takes you to a specific form.

 

what i currently have is this:

<?php 
$type = $_POST['ResCom'];
if (!isset ($type)) {
echo '<div align="center">
<form name="ResCom" method="post" action="estimate.php">
  <p>Click on the type of cleaning project you want an estimate on. </p>
  <p>
    <input name="Res" type="submit" id="Res" value="Residential">
    <input name="Com" type="submit" id="Com" value="Commercial">
    </p>
</form>
</div>
';}

elseif ($type = 'Residential')
{echo 'Residential';}

else {echo 'Commercial';}

?>

 

it isn't recognizing that $type is set... (i also tried saying

else if ($type = 'Res')...

 

i'm very confused, but you guys will probably find the problem in two seconds and make me feel stupid...

 

thanks in advance.

 

ardy

Link to comment
Share on other sites

It wont ever change by $type unless you assign it properly on residential like you did above and I'm guessing you want to check if it isset like above also if you wanted to check if it was = to you would use a double == sign, but this is all speculation.

Link to comment
Share on other sites

this is pretty quick update but look

 

<?php 
   if(!isset($_POST['Res']) && !isset($_POST['Com'])){

      echo '<div align="center"><form name="ResCom" method="post" action="help.php">
	<p>Click on the type of cleaning project you want an estimate on. </p>
	<p><input name="Res" type="submit" id="Res" value="Residential">
	<input name="Com" type="submit" id="Com" value="Commercial">
	</p></form></div>';

}elseif(isset($_POST['Res'])){
echo 'Residential';
}else{
echo 'Commercial';
}

?>

Link to comment
Share on other sites

thanks a lot...

 

like i have said in other posts, i am totally new to php, and appreciate all of the help.

 

your changes worked like a charm!  dont really understand how (i thought that if you used && it would make sure that both are set, where you can only click one button.....)  i really need to take a good class online or something, tutorials just aren't enough...

 

thanks again.

 

ardy

Link to comment
Share on other sites

this is your error

elseif ($type = 'Residential')

you're not trying to condition but rather you're trying to assign a value to $type

so its true because you have successfully assigned the value

 

it should be

elseif ($type == 'Residential')
or
elseif ($type === 'Residential')

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.