0% found this document useful (0 votes)
190 views

Dreamweaver Password Protected Page Code

This document contains code for password protecting a webpage with JavaScript and validating and sending a contact form with PHP. The JavaScript code prompts the user for a password and redirects if incorrect. The PHP code validates the name, email, and comment fields are entered, and sends an email with the submitted values if valid.

Uploaded by

Mna Azmy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
190 views

Dreamweaver Password Protected Page Code

This document contains code for password protecting a webpage with JavaScript and validating and sending a contact form with PHP. The JavaScript code prompts the user for a password and redirects if incorrect. The PHP code validates the name, email, and comment fields are entered, and sends an email with the submitted values if valid.

Uploaded by

Mna Azmy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Dreamweaver password protected page code

<SCRIPT language=”JavaScript”>
<!--hide
Var password;
Var pass1=”your password”
Password=prompt(‘please enter the password to view
this page’’,’’);
If(password==pass1)
Alert(‘password correct click ok to enter’);
Else
(
Window.location=’your link’;
)
//-->
</SCRIPT>
FORM TO EMAIL CODE
1. <?php
2.  
3.  
4.  
5. if (isset($_POST['submit'])){
6.        
7.         $name = $_POST['name'];
8.         $email = $_POST['email'];
9.         $comments = $_POST['comments'];
10.        
11.         $to = "YOUR EMAIL HERE";
12.         $subject = "New Contact us form";
13.         $message = "A new message has been sent by $email \n
14.         Their message was $comments \n \n
15.         Their Details: \n
16.         Name: $name \n
17.         Email $email \n";
18.        
19.        
20.         if ($name) {
21.                
22.                
23.                 if($email) {
24.                        
25.                         if ($comments){
26.                                
27.                                 mail ($to, $subject, $message);
28.                                
29.                                 echo "Thank you for your
comments";
30.                                
31.                                
32.                                
33.                         } else {
34.                                
35.                                 echo "Please enter some
comments";
36.                         }
37.                        
38.                        
39.                 } else {
40.                        
41.                         echo "Please enter an email
address";
42.                 }
43.                
44.         } else {
45.                
46.                 echo "Please enter your name";
47.                
48.         }
49.        
50.        
51.        
52. } else {
53.  
54. //Form Built by TPGS   
55. ?>
56.  
57.                         <form action="contact.php"
method="post">
58.                         Name: <input type="text" name="name"
/><br /><br />
59.                         Email: <input type="text"
name="email" /><br /><br />
60.                         Comments: <textarea name="comments"
rows="20" cols="40"></textarea><br /><br />
61.                         <input type="submit" name="submit"
value="Send Form" />
62.                        
63.                         </form>
64.  
65.  
66. <?php
67. }
68.  
69. ?>

You might also like