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

create a field and name it say "promo" and then do this:

 

<?php

$entrycode = $_POST['$entrycode''];

// connect to db
// select db
$contentsearch = mysql_query("select promo from tblName where promo='$entrycode'") or die("Invalid Promotional Code");

?>

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.

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

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.