Jump to content

login form question


mervyndk

Recommended Posts

I'm trying to create a login form for my website. It needs to have any user enter a set password as well as their own name and e-mail address (they will not have to register). Their name and e-mail address will be sent to my e-mail address, while the password is used for simple guest authentication (I only want people I have told about the website to be able to get it - fingers crossed!).

 

I've had no problem in creating the name/e-mail form and php script, but don't know how to get the password included. Here's the script I'm using for the name/e-mail. Ideally, the password would be protecting access to all pages in the site. Any help would be greatly appreciated.

 

<?

 

// ------------- CONFIGURABLE SECTION ------------------------

 

// $mailto - set to the email address you want the form

// sent to, eg

//$mailto = "[email protected]" ;

 

$mailto = '[email protected]' ;

 

// $subject - set to the Subject line of the email, eg

//$subject = "Feedback Form" ;

 

$subject = "Your Website has had a visitor" ;

 

// the pages to be displayed, eg

//$formurl = "http://www.example.com/feedback.html" ;

//$errorurl = "http://www.example.com/error.html" ;

//$thankyouurl = "http://www.example.com/thankyou.html" ;

 

$formurl = "http://www.mysite.com/index.htm" ;

$errorurl = "http://www.mysite.com/error.htm" ;

$thankyouurl = "http://www.mysite.com/firstpage.htm" ;

 

// -------------------- END OF CONFIGURABLE SECTION ---------------

 

//$name = $_POST['name'] ;

//$email = $_POST['email'] ;

//$comments = $_POST['comments'] ;

$email=htmlentities($_POST['email']);

$fname=urldecode($_POST['fname']);

 

if (!isset($_POST['email'])) {

header( "Location: $formurl" );

exit ;

}

if (empty($fname) || empty($email)) {

  header( "Location: $errorurl" );

  exit ;

}

$name = strtok( $name, "\r\n" );

$email = strtok( $email, "\r\n" );

if (get_magic_quotes_gpc()) {

$comments = stripslashes( $comments );

}

 

//List of Headers

$headers.="Content-type: text/html; charset=iso-8859-1\r\n";

$headers.="From: $email\r\nReply-To: $email";

header( "Location: $thankyouurl" );

 

$messageproper = "

First Name: $fname <br>

E-mail Address: $email <br>

.

 

";

 

//mail() function sends the mail

mail($mailto,$subject,$messageproper,$headers)

 

?>

Link to comment
https://forums.phpfreaks.com/topic/105939-login-form-question/
Share on other sites

<?php
$password = "somepassword";
if ($_POST['password'] == $password){
// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto      = "[email protected]" ;

$mailto = '[email protected]' ;

// $subject - set to the Subject line of the email, eg
//$subject   = "Feedback Form" ;

$subject = "Your Website has had a visitor" ;

// the pages to be displayed, eg
//$formurl      = "http://www.example.com/feedback.html" ;
//$errorurl      = "http://www.example.com/error.html" ;
//$thankyouurl   = "http://www.example.com/thankyou.html" ;

$formurl = "http://www.mysite.com/index.htm" ;
$errorurl = "http://www.mysite.com/error.htm" ;
$thankyouurl = "http://www.mysite.com/firstpage.htm" ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

//$name = $_POST['name'] ;
//$email = $_POST['email'] ;
//$comments = $_POST['comments'] ;
$email=htmlentities($_POST['email']);
$fname=urldecode($_POST['fname']);

if (!isset($_POST['email'])) {
   header( "Location: $formurl" );
   exit ;
}
if (empty($fname) || empty($email)) {
   header( "Location: $errorurl" );
   exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
   $comments = stripslashes( $comments );
}

//List of Headers
$headers.="Content-type: text/html; charset=iso-8859-1\r\n";
$headers.="From: $email\r\nReply-To: $email";
header( "Location: $thankyouurl" );

$messageproper = "
First Name: $fname

E-mail Address: $email

.   

";

//mail() function sends the mail
mail($mailto,$subject,$messageproper,$headers)
}
else{
//do something
}
?>

Link to comment
https://forums.phpfreaks.com/topic/105939-login-form-question/#findComment-542894
Share on other sites

oops. overlooked something. here

<?php
$password = "somepassword";
if ($_POST['password'] == $password){
// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto      = "[email protected]" ;

$mailto = '[email protected]' ;

// $subject - set to the Subject line of the email, eg
//$subject   = "Feedback Form" ;

$subject = "Your Website has had a visitor" ;

// the pages to be displayed, eg
//$formurl      = "http://www.example.com/feedback.html" ;
//$errorurl      = "http://www.example.com/error.html" ;
//$thankyouurl   = "http://www.example.com/thankyou.html" ;

$formurl = "http://www.mysite.com/index.htm" ;
$errorurl = "http://www.mysite.com/error.htm" ;
$thankyouurl = "http://www.mysite.com/firstpage.htm" ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

//$name = $_POST['name'] ;
//$email = $_POST['email'] ;
//$comments = $_POST['comments'] ;
$email=htmlentities($_POST['email']);
$fname=urldecode($_POST['fname']);

if (!isset($_POST['email'])) {
   header( "Location: $formurl" );
   exit ;
}
if (empty($fname) || empty($email)) {
   header( "Location: $errorurl" );
   exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
   $comments = stripslashes( $comments );
}

//List of Headers
$headers.="Content-type: text/html; charset=iso-8859-1\r\n";
$headers.="From: $email\r\nReply-To: $email";
header( "Location: $thankyouurl" );

$messageproper = "
First Name: $fname

E-mail Address: $email

.   

";

//mail() function sends the mail
mail($mailto,$subject,$messageproper,$headers);
}
else{
//do something
}
?>

Link to comment
https://forums.phpfreaks.com/topic/105939-login-form-question/#findComment-542913
Share on other sites

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.