acctman Posted August 20, 2008 Share Posted August 20, 2008 Hi can someone assist me in writing the code properly for to process my form. I've written out how the code should work below in the PHP section. thanks <form method="post" action="/modules/rating/process_regimg.php" enctype="multipart/form-data"> <input type="hidden" name="gender" value="1" /> <input type="checkbox" name="imgcrop" checked="unchecked" /> <input name="Submit" type="submit" value="Next Step!" /> <?php 1. $_SESSION['reg_gender'] = input name gender value 1 or 2 2. If 'imgcrop' checkbox is unchecked... AND input name gender value 1 header('Location: reg_female.php'); 3. If 'imgcrop' checkbox is unchecked... AND input name gender value 2 header('Location: reg_male.php'); 4. If 'imgcrop' checkbox is check then... header('Location: imgcrop.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/120467-solved-form-processing/ Share on other sites More sharing options...
Third_Degree Posted August 20, 2008 Share Posted August 20, 2008 if ( $_POST['imgcrop'] != 'on' && $_POST['gender'] == '1' ) if ( $_POST['imgcrop'] != 'on' && $_POST['gender'] == '2' ) if ( $_POST['imgcrop'] == 'on' ) Quote Link to comment https://forums.phpfreaks.com/topic/120467-solved-form-processing/#findComment-620759 Share on other sites More sharing options...
Fadion Posted August 20, 2008 Share Posted August 20, 2008 The full code should be: <?php $check = $_POST['checkbox']; $gender = $_POST['gender']; if($check != 'on'){ if($gender == 1){ header('Location: reg_female.php'); } elseif($gender == 2){ header('Location: reg_male.php'); } } else{ header('Location: imgcrop.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/120467-solved-form-processing/#findComment-620902 Share on other sites More sharing options...
acctman Posted August 20, 2008 Author Share Posted August 20, 2008 The full code should be: <?php $check = $_POST['checkbox']; $gender = $_POST['gender']; if($check != 'on'){ if($gender == 1){ header('Location: reg_female.php'); } elseif($gender == 2){ header('Location: reg_male.php'); } } else{ header('Location: imgcrop.php'); } ?> thanks. one other question is it better to put the gender value in to a session? so, if imgcrop.php is loaded the user crop there image and have the session called to redirect to the correct user reg page. I know how to do that part, was just wondering if thats the best method Quote Link to comment https://forums.phpfreaks.com/topic/120467-solved-form-processing/#findComment-621231 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.