Jump to content


Photo

Simple Enough question, but i really need help =)


  • Please log in to reply
26 replies to this topic

#1 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 07:39 PM

Hey, I have a fully functionaly contact.php file that submits me data from my website, but unfortunately people are able to just click submit as many times as they want and it will send to me a blank email. Is there a way to stop this? Like if someone does not fill in the form then it will not be sent and redirect to an error page this is what i have so far if someone were to correct me and fill in what i need to do this i would be greatly appreciative. thanx!

*No real sites, emails used fake ones for privacy reasons

<?php
@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: anywebsite.com");
?>

Now is there a code i can add to redirect my visitors to "errorwebsite.com" if they do not fill in 'username' or 'password'?

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 17 July 2006 - 07:45 PM

You could/should do a couple of things

1. use some string functions like trim, and/or strlen to make sure the variable contain data.

2. you could also check to make sure the variables only contain certain characters, ie alphanumeric

3. use a captcha to add a little more protection

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 07:48 PM

I like just started coding and i have no idea what any of that means so if anyone knows how to fix this and actually are able to write the code that would enable visitors to be redirected to a "errorsite.com" if they do not complete the form and click submit please do so, because suggestions and advise do nothing for me im noobish but thanks for any help!

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 07:48 PM

<?php

if((!$email=="none")&&($password=="none")&&($name=="none")){
echo " sorry fill in the dam form";

}elseif if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email)) {

echo"please add a correct email address</a>";
}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: anywebsite.com");
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 07:49 PM

hahaha u are the guru thanx a ton!

#6 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 07:53 PM

would this work to or how would i do something more like this?

<?php

if((!$username=="none")&&($password=="none")){
echo("Location: Errorsite.com");
}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: somesite.com");
?>


#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 07:55 PM

try this ok.

<?php

if((!$email=="none")&&($password=="none")&&($name=="none")){
echo " <font color='red'>sorry fill in the dam form</font>";

}elseif if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email)) {

echo"<font color='red'>Please add a correct email address</font>";
}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: anywebsite.com");
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 07:57 PM

is there a way to redirect them to another website... not just text but like a whole other website if they do not fill it in?

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 08:03 PM

<?php

if((!$email=="none")&&($password=="none")&&($name=="none")){

header(location: what_ever.com");

}elseif if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email)) {

header(location: what_ever.com");

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");

header("Location: anywebsite.com");
}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:12 PM

why would i need

if((!$email=="none")&&($password=="none")&&($name=="none")){

header(location: what_ever.com");

}elseif if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email)) {

header(location: what_ever.com");

}

i have only username and password option so would it be like this?

if((!$username=="none")&&($password=="none")){

header(location: what_ever.com");

}elseif if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email   *There is no email option what should go here?)) {

header(location: what_ever.com");

}


#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 08:13 PM

Sorry i thort you had a email address in the form to see if the emaill was valid sorry.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:23 PM

np thanks for helping me tho! if i did want to have a reply "echo" would this be correct?

<?php

if(!$username="none")&&(!$password="none")){

echo "<font color="white"><b>Invalid Username or Password</b></font>";

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: site.com");
?>


#13 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:32 PM

this gives me an error:

Parse error: parse error, unexpected ':' in /home/dothost.eu/vhosts/shisamandisa.43i.org/test.php on line 5

#14 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 08:34 PM

<?php

if(!$username="none")&&(!$password="none")){

echo "<font color='white'><b>Invalid Username or Password</b></font>";

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: site.com");
?>


"  '  ' " double quote single quote ect ect ect ok
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#15 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:37 PM

Parse error: parse error, unexpected T_BOOLEAN_AND in /home/dothost.eu/vhosts/shisamandisa.43i.org/test.php on line 3

#16 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 08:39 PM

== sorry edited ( sorry
<?
if((!$username=="none")&&(!$password=="none")){

echo "<font color='white'>Invalid Username or Password</font>";

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");
header("Location: site.com");
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#17 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:48 PM

dammit so many errors:

Warning: Cannot modify header information - headers already sent by (output started at /home/dothost.eu/vhosts/shisamandisa.43i.org/test.php:5) in /home/dothost.eu/vhosts/shisamandisa.43i.org/test.php on line 13

#18 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 08:52 PM

try that ok
<?
if((!$username=="none")&&(!$password=="none")){

echo "<font color='white'>Invalid Username or Password</font>";

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");

if(($username)&&($password)){
header("Location: site.com");
}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#19 shisamandisa

shisamandisa
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 08:59 PM

sweet thanks we are get much closer and i owe u for this. the only problem is....

<?
if((!$username=="none")&&(!$password=="none")){
header("Location: error.html");

}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");

if(($username)&&($password)){
header("Location: header.html");
}
?>

If someone doesnt fill out anything it will redirect them to the error page and if they do fill it in it will redirect them to the thank you page, but is their a way to not have a blank email sent if they dont fill it out because even tho the are redirected to an error (please fill out form) page the unfinished form is still sent

#20 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 09:03 PM

try this ok

<?
if((!$username=="none")&&(!$password=="none")){
header("Location: error.html");
exit;
}

@extract($_POST);
$username=$_POST['username'];
$password=$_POST['password'];
mail("email@gmail.com", $username, $password, "From: $username");

if(($username)&&($password)){
header("Location: header.html");
exit;
}
?>

added exit ok if error
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users