Jump to content

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

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.