Forum Moderators: coopster

Message Too Old, No Replies

Want to implement a script..

         

Bubzeebub

5:40 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



I went to a popular script and saw a script that seems to fit my needs. However, I downloaded it(It's a .tar file)and I don't know what to do now to 1) open it and 2) implement it into my site.

Also, I'm concerned about security. Are there security issues to be concerned with when using a script online like this?

hakre

5:44 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



(not a php only issue) by using a script you do not fully understand, you risk executing something that can endanger the computer system it's running on.

tar can be "unpacked" with gzip or the tar util under linux. for windows, you can use totalcommander or winrar.

grandpa

5:55 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



At the very least scan it for the mail function :(

WinZip should open it too. Extract the contents to a directory of your choosing, and look it over before you use it. You should find a helpful README or other document if it requires any installation.

[edited by: grandpa at 5:57 pm (utc) on Feb. 18, 2005]

Bubzeebub

5:56 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



I'm looking to create a form on a site where a visitor can enter in information that's checked against a database. If the credentials entered are correct, the user will be redirected to another page within the site. I have PHP and mySQL to do this but I don't have a CLUE how to use them or what I need to solve the problem. I saw a script that I was looking to use and it apparently doesn't require a database as it uses PHP sessions. Would this be a good solution or are there other concerns I might not be noticing?

hakre

8:36 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



on the first look sessions should be very ok for that and can even be a good solution. if you don't know php nor mysql, you need to take someone else script because you can't write your own. me personally i won't do so when it comes to security but i can write php and know what's secure and what's not. but this won't help you right now. i think you should think about "how much" security you need.

Bubzeebub

8:45 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



Security isn't real important to me in this particular case. I'm using the code below to create a simple form. It's a sample form that I grabbed online that I'd like to use. The url you see there is fictitious. The problem is I'm not sure what other parts of it I need to customize to my needs.

<span class="style8"></span><br>
<br>
<p>Please enter your promo code below: <form name="promo_code_form" action="http://www.example.com/promos_entry.php?osCsid=606f6c2c0d6a3e04d6e75c3db32c3c11" method="GET">
<input type="text" name="promo_code" maxlength=6, size=8>
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit">
<br>
</p>
</div>
</TD>
</TR>
</TABLE></td>
</tr>

Can anyone shed some light on this? I'd really appreciate it. Thanks!

[edited by: jatar_k at 9:51 pm (utc) on Feb. 18, 2005]
[edit reason] generalized [/edit]

hakre

9:05 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it would be interesting to know, what "promos_entry.php" is doing. otherwise this is only a form which should be no problem at all.

Bubzeebub

9:08 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



see..that's just it. That ACTION= line was part of the sample form. I don't think I'll need to use it since it was probably customized for whomever was using that script before. The problem is, I'm not sure what the ACTION= line does and what I would need to do to make it work for me.

hakre

9:15 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the action="..." line simply names the adress (url) to where the data of the form is send to after pressing the submit button. that's all. if it would be action="http://www.google.com/" all data would be send to google.com (that would be useless, but it's just an example). thats action=.

Bubzeebub

10:10 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



I have the script that I'm using...but I'm stuck. Can anyone help? ;o(

jatar_k

11:08 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you changed the form action in your input form to target your script that processes the input?

Bubzeebub

6:26 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



Maybe I should clarify a bit because I'm a bit confused. This is the code that I have thus far:

<html>
<head>
<title>Login Page</title>
</head>
<body bgcolor="white">
<p><span class="style8"></span><br>
<br>
</p>
<p>Please enter your promo code below: <form name="promo_code_form" action="http://www.example.com" method="GET">
<input type="text" name="promo_code" maxlength=6, size=8>
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit">
<br>
</p>
<?
//if no cookie is set then display the form
if(!isset($_COOKIE["this_cookie"])){
echo '<div align="center"><form action="validate.php" method="post">';
echo 'username : <input type="text" name="username"><br><br>';
echo 'password : <input type="password" name="password"><br><br>';
echo '<input type="submit" value="login"></form></div>';
}else{
echo "You are already logged in. <a href=\"1.php\">Continue</a>";
}
?>
</td>
</tr>
</table>
</body>
</html>

In Dreamweaver, this code looks fine. It shows up as a small form box with a 'Submit' button to the right. The problem now is that I don't know what I need to do at this point so that a user can enter in a code and then be forwarded to another internal page. I have mySQL and PhP. Any help would be GREATLY appreciated!

ogletree

6:30 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Most script sites will have a place where people rate it. If it has somethig bad in it they may point it out.

jatar_k

6:40 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



<form name="promo_code_form" action="http://www.example.com" method="GET">

that line above is wrong, if the user clicks the submit button the information in the form will be sent to the script specified in the action

Set the action to the script

if your script is called process.php and is located in a folder named scripts that is located in the root of your site then your form tag would look like this

<form name="promo_code_form" action="/scripts/process.php" method="GET">

you also want to set the method to post I would think, so

<form name="promo_code_form" action="/scripts/process.php" method="POST">

understand?

Bubzeebub

7:45 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



yes..I understand...but do I need mySQL and PhP for what I'm trying to do or is this overkill?

jatar_k

7:51 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, at this point you would need to take the information that was entered into your form and check it against some record you keep to see if the information is correct in order to know where, or if, you should redirect them.

That would depend on the amount of information you have to compare it to. If you send out a single promo code for everyone then mysql would be overkill. On the other hand if there are seperate promo codes per email address and there are a bunch of them then mysql will fit the bill nicely.

PHP, yes, you will need some sevrer side scripting to validate and compare the data and then send them off to where they need to go.

So, first things first.

We now have a form, ok, that covers how we get input from users.

Are you going to maintain a user base? Will they have to sign up an account with you?

Do you have promo codes that are tied to existing users, new possible users or both? How many codes are there?

What are all the possible scenarios that can occur once information is entered into the script?

no account? - sign up
bad data? - tell them what is wrong and redisplay the script
invalid promo code? - some kind of error I would think

what else can you think of?

Bubzeebub

8:08 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



Well I'm using it so that if I run an ad campaign I can track where the users are coming from. For example, if I run a newspaper ad, I can have customers who saw that ad enter in the code 'PAPER' to receive a discount. I more than likely will have several different codes (no more than 5 or 10 at the most)

Bubzeebub

8:10 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



If the code entered in is incorrect, then they would just stay on the same page.

jatar_k

8:12 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



so is it just a one off or are they actually going to have and maintain an account with you?

Bubzeebub

11:21 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



nope...they won't need an account or id. They'll just enter the code. If the code is correct they'll be redirected to an internal web page.

PLEASE...if anyone can help with this I will appreciate it. Thank you...Thank you.

[edited by: ergophobe at 1:48 am (utc) on Feb. 20, 2005]
[edit reason] deleted bump and combined posts [/edit]

jatar_k

10:30 pm on Feb 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



dead easy then, hard code it

form would be something like this

promoform.php
<?php
if (isset($errmsg)) echo '<p>',$errmsg;
?>
<p><form name="mypromo" method="get" action="checkpromo.php">
<input type="text" name="pcode" size="20"> <input type="submit" value="Go">
</form>

now the checkpromo.php needs to be in the same directory, it would look something like this

checkpromo.php

<?php 
$errmsg = "";
if (empty($_POST['pcode']) ¦¦!isset($_POST['pcode'])) {
$errmsg = 'Please enter a promotional code';
include 'promoform.php';
} else {
$promocode = trim(strtolower($_POST['pcode']));
switch($promocode) {
case "paper":
$redirectpage = 'paper.php';
break;
case "radio":
$redirectpage = 'radio.php';
break;
case "magazine":
$redirectpage = 'magazine.php';
break;
}
header("Location: $redirectpage");
}
?>

You would just need to put in the real promo codes and the appropriate pages to redirect to.

remember WebmasterWorld breaks pipe ¦ characters these must be replaced with real pipe characters

Bubzeebub

4:26 am on Feb 21, 2005 (gmt 0)

10+ Year Member



Gotcha gotcha. Thanks Jatar. The only thing I'm not sure of is where exactly I need to enter in page the user will be redirected to. I want to make sure I put it in the right area and have it in the right format.

jatar_k

5:02 am on Feb 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



'paper.php'
'radio.php'

that does a different one for each promo code, just change the above to the appropriate page

Bubzeebub

5:29 am on Feb 21, 2005 (gmt 0)

10+ Year Member



ok..I'll give that a shot..thanks.

Bubzeebub

11:48 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



so if I wanted to send someone to www.widgets.com after they entered in "radio" would this be the correct format?:

case "paper": $redirectpage = [widgets.com;...] break;

Bubzeebub

4:06 am on Feb 28, 2005 (gmt 0)

10+ Year Member



Can anyone help with the format of this code above that Jatar suggested to redirect the user to a different page after they enter in the promo code? I don't think it's difficult for you experts, but I'm just a newbie.

Thanks.