Jump to content

[SOLVED] Form processing


acctman

Recommended Posts

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');

?>



Link to comment
https://forums.phpfreaks.com/topic/120467-solved-form-processing/
Share on other sites

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');
}
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.