Jump to content

I would I implement a single promotional code for login


ducky101

Recommended Posts

Hi,

 

I'm trying to create a form where people can register by entering their names, email addresses and one "promotional" code  (the same for everyone).

 

The names and emails I've got, I just can't seem to wrap my head around the notion of one single access code.

 

I mean, do I create a new table for just one value or do I have to do something else, and also what would the query look like?

 

I hope someone can help me.

 

Thanks in advance.

 

Alex

Link to comment
Share on other sites

If its the same promo code for everyone and if you don't plan to change it, I wouldn't even bother storing it in a field of a DB and just hard code it.  But if there is any chance you'll change that, then putting it in a DB would be a good idea.

Link to comment
Share on other sites

Thank you all for the help you have provided  :D

I am new to php, but even now with this short experience I can tell it is a wonderfull community.

This will certainly add to the joy of learning to program in php.

 

As for the solution, I have gone with the database option.

I created a new table called promo with field promocode

In my php script I did:

 

//Connect to db stuff
$promocode = $_POST ['promocode]; 

$PromocodeQuery = mysql_query("SELECT * FROM promo WHERE promocode='$promocode");
$promocode = strtolower ($promocode);
$PromocodeExist = mysql_num_rows($PromocodeQuery); // Return 0 if it doesn't exist 

 

Then I added logic

 

if ($InlogcodeExist == 0)
{
	print "<p><font size=\"3\" face=\"Myriad Pro, Arial\" color=\"#E08734\"><b>Promocode is not correct!</b></font></p>";
	exit;

}
else 
{ //rest of the script I want to run}

 

And it works like a charm

 

Anyway thanks for the help again.

 

Alex

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.