Code More people want.Because this is also a method to
increase site traffic.and its is a best method of increasing
site traffic so i think i share you this trick.
to follow my some simple steps.
tellafriend.php
name.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
| <?php / * Tell A Friend Script: * This script allows your visitors to sent invitation to their friends via email to visit your site. * * Usage: * The script comes with three files tellafriend.php, thankyou.html and install.txt * You're NOT allowed to redistribute or sell this script. * You are allowed to modify this script for your own personal use. * Please see install.txt attached in the zip for installation instructions. * * Notes: * If you like this script or used it for your website or project. * Please remember too link back to www.shubhamtipstricks.com. * Your help is always appreciated. * * author: Shubham Kumar (shubhamtipstricks.com) * Visit www.shubhamtipstricks.com (or www.shubhamtipstricks.com) for more script and tutorials on PHP. //minimum characters allowed in the message box $msg_min_chars = "10" ; //maximum characters allowed in the message box $msg_max_chars = "250" ; $errors = array (); function validate_form_items() { global $msg_min_chars , $msg_max_chars ; $msg_chars = "{" . $msg_min_chars . "," . $msg_max_chars . "}" ; $form_items = array ( "name" => array ( "regex" => "/^([a-zA-Z '-]+)$/" , "error" => "Your name appears to be in improper format" , ), "email" => array ( "regex" => "/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+) (([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/" , "error" => "email address is invalid" , ), "message" => array ( "regex" => "/.*/" , "error" => "Your message is either too short or exceeds $msg_max_chars characters" , ), ); global $errors ; if (!preg_match( $form_items [ "name" ] [ "regex" ], $_POST [ "your_name" ])) $errors [] = $form_items [ "name" ] [ "error" ]; if (!preg_match( $form_items [ "email" ] [ "regex" ], $_POST [ "your_email" ])) $errors [] = "your " . $form_items [ "email" ][ "error" ]; if (!preg_match( $form_items [ "email" ] [ "regex" ], $_POST [ "friend_email1" ])) $errors [] = "Friend 1 " . $form_item s [ "email" ][ "error" ]; if ( strlen (trim( $_POST [ "message" ])) < $msg_min_chars || strlen (trim ( $_POST [ "message" ])) > $msg_max_chars ) $errors [] = $form_items [ "message" ][ "error" ]; if (trim( $_POST [ "friend _email2" ]) != "" ) { if (!preg_match( $form_items [ "email" ][ "regex" ], $_POST [ "friend_email2" ])) $errors [] = "Friend 2 " . $form_items [ "email" ][ "error" ]; } if (trim( $_POST [ "friend_email3" ]) != "" ) { if (!preg_match( $form_items [ "email" ][ "regex" ], $_POST [ "friend_email3" ])) $errors [] = "Friend 3 " . $form_items [ "email" ][ "error" ]; } return count ( $errors ); } function email( $from , $from_name , $to , $message ) { //header("Location: thankyou.html");return; $headers .= "From: " . $from . "\r\n" ; $headers .= "Content-type: text/plain; charset=ISO-8859-1" ; $your_domian_name = "www.shubhamtipstricks.com" ; //edit what you want your vistors to see in their email here $subject = $from_name . " sent you an invitation to $your_domian_name" ; $your_message = "Hi!\r\n" ; $your_message .= ucfirst( $from_name ); $your_message .= " wants you to check out $your_domian_name\r\n" ; $your_message .= "Sender's Message:\n\r" ; $message = $your_message . stripslashes ( $message ); if (mail( $to , $subject , $message , $headers ) ) { return true; } else { return false; } } function print_error( $errors ) { foreach ( $errors as $error ) { $err .= $error . "<br/>" ; } echo "<div style=\"border:1px red solid; font-size:14px; font-weight:normal; color:red; margin:10px; padding:10px;\"> $err <div>"; } function form_process() { $from_name = $_POST [ "your_name" ]; $from_email = $_POST [ "your_email" ]; $to = $_POST [ "your_email" ]. "," . $_POST [ "friend_email1" ]. "," . $_POST [ "friend_email2" ]. "," . $_POST [ "friend_email3" ]; $message = $_POST [ "message" ]; $error_count = validate_form_items(); if ( $error_count == 0) { if (email( $from_email , $from_name , $to , $message )) header( "Location: thankyou.html" ); else { global $errors ; $errors [] = "Email coudn't be send at this time. <br>Please report the webmaster of this error." ; } } } if (isset( $_POST [ "submit" ])) form_process(); ?> <html> <title>php-learn-it.com - Email Form Script</title> <head> </head> <body> <form id= "test" method= "post" action= "<?php echo $PHP_SELF?>" > <table border= "0" > <tr> <td colspan= "2" style= "border- bottom:1px solid black;" > <font size= "+2" ><b>Tell A Friend</b></font> </td> </tr> <tr> <td colspan= "2" > <?php global $errors ; if ( count ( $errors ) != 0){ print_error( $errors ); } ?> </td> </tr> <tr> <td> <b>Your Name:*</b> </td> <td> <b>Your Email:*</b> </td> </tr> <tr> <td> <input type= "text" name= "your_name" id= "name" size= "20" maxlength= "25" value= "<?php echo $_POST[" your_name "]?>" > </td> <td> <input type= "text" name= "your_email" id= "email" size= "31" maxlength= "80" value= "<?php echo $_POST[" your_email "]?>" > </td> </tr> <tr> <td colspan= "2" > <b>Friend's Email:</b>*<br/> <input type= "text" name= "friend_ email1" id= "name" size= "56" maxlength= "80" value= "<?php echo $_POST[" friend_email1 "]?>" > </td> </tr> <tr> <td colspan= "2" > <b>Friend's Email:</b><br/> <input type= "text" name= "friend_email2" id= "name" size= "56" maxlength= "80" value= "<?php echo $_POST[" friend_email2 "]?>" > </td> </tr> <tr> <td colspan= "2" > <b>Friend's Email:</b><br/> <input type= "text" name= "friend_email3" id= "name" size= "56" maxlength= "80" value= "<?php echo $_POST[" friend_email3 "]?>" > </td> </tr> <tr> <td> <b>Message:*</b> </td> <td> <i>(max 250 characters allowed)</i> </td> </tr> <tr> <td colspan= "2" > <textarea name= "message" id= "message" cols= "42" rows= "5" ><?php echo $_POST [ "message" ]?></textarea> </td> </tr> <tr> <td colspan= "2" align= "right" > <i>(* required fields)</i> <input type= "submit" value= "submit" name= "submit" > </td> </tr> </table> </form> </body> </html> |
1
2
3
4
5
6
7
| < html > < title >Thank you</ title > < body > < span align = "center" >Thank you. You email has been sent to your friend(s).< br > < input type = button value = "Close Window" onClick = "javascript:window.close();" > </ body > </ html > |
0 comments:
Post a Comment