ardyandkari Posted March 10, 2008 Share Posted March 10, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/95300-select-different-forms-script/ Share on other sites More sharing options...
Cardale Posted March 10, 2008 Share Posted March 10, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/95300-select-different-forms-script/#findComment-488128 Share on other sites More sharing options...
Cardale Posted March 10, 2008 Share Posted March 10, 2008 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'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/95300-select-different-forms-script/#findComment-488130 Share on other sites More sharing options...
ardyandkari Posted March 10, 2008 Author Share Posted March 10, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/95300-select-different-forms-script/#findComment-488167 Share on other sites More sharing options...
teng84 Posted March 10, 2008 Share Posted March 10, 2008 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') Quote Link to comment https://forums.phpfreaks.com/topic/95300-select-different-forms-script/#findComment-488171 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.