Jump to content

trying to figure this code out


RoseG

Recommended Posts

I am trying to redirect users depending on their coupon code input

 

I am using the following script in the form created in dreamweaver:

 

<form action="CodeUserredirect.php" method="post" enctype="multipart/form-data" name="" id="">
  <input type="hidden" name="redirect" value="CodeUserredirect.php" />
    <p class="style4">Redeem your Gift Certificate Savings for Special Orders here:</p>
    <p><span class="style78">Enter Coupon code</span>
      <input name="CouponCode" type="text" id="CouponCode" size="9">
      <input type="submit" name="CheckCode" id="CheckCode" value="Check Code">
      <br/>
      <br/>
    </p>
  </form>

 

 

and I am using the following code in my php file:

 

<?php

$coupon_code = $_POST['couponcodenumber'];

 

if ($coupon_code = $some_other_value) {

 

    $redirected_address = 'Location: specialordersDiscountForm.php';

    header ($redirected_address);

    exit();

} else {

    $redirected_address = 'Location: specialorderwrongcode.php';

    header ($redirected_address);

    exit();

}

?>

 

Not sure where the issue is in these coding but it is not working to redirect users depending on their coupon input as intended.  Can anyone supply me with a working code or explain what the issue is? 

 

thanks!

Link to comment
Share on other sites

the if statement has only 1 = sign thats probably where its falling over.

 

Thanks Spiderwell, but when I add two ='s it only takes me to the last redirected page no matter what the user enters,  I will like it to go to one page if they enter the correct coupon code or the other if entered wrong.

 

Thanks!

Link to comment
Share on other sites

have you put a value into the $some_other_value variable?

<?php
$coupon_code = $_POST['couponcodenumber'];
if ($coupon_code == $some_other_value) 
{  
header ('Location: specialordersDiscountForm.php');
exit();
} 
else 
{    
	header ('Location: specialorderwrongcode.php');   
	exit();
}
?> 

Link to comment
Share on other sites

have you put a value into the $some_other_value variable?

<?php
$coupon_code = $_POST['couponcodenumber'];
if ($coupon_code == $some_other_value) 
{  
header ('Location: specialordersDiscountForm.php');
exit();
} 
else 

{    
	header ('Location: specialorderwrongcode.php');   
	exit();
}
?> 

 

If I put the coupon code number there as well it still takes users to the page they should be at when they get the code wrong.  it takes them there whether the code they enter is correct or not.

Link to comment
Share on other sites

from the given form, I do not see an input value with name='couponcodenumber', which means $_POST['couponcodenumber'] will never exist, and never equal $some_other_value (we have no clue where $some_other_value is coming from either). That being said, the correct $_POST index, according to your code, should be $_POST['CouponCode']:

 

$coupon_code = $_POST['CouponCode'];
if ($coupon_code == $some_other_value) 
{    
header ("Location: specialordersDiscountForm.php");
exit();
} 
else 
{    
header ("Location: specialorderwrongcode.php");    
exit();
}

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.