Pages

Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Wednesday, December 29, 2010

A Practical PHP Form to Mail

This is an HTML form for sending email




<html><body><font face=Arial size=2>

<form method="post" action="contact.php">

<table bgcolor=#ffffcc align=center>

<tr><td colspan=2><strong>Contact us using this form:</strong></td></tr>

<tr><td>Department:</td><td><select name="sendto"> <option value="info@mycompany.com">General</option> <option value="support@mycompany.com">Support</option> <option value="sales@mycompany.com">Sales</option> </select></td></tr>

<tr><td><font color=red>*</font> Name:</td><td><input size=25 name="Name"></td></tr>

<tr><td><font color=red>*</font> Email:</td><td><input size=25 name="Email"></td></tr>

<tr><td>Company:</td><td><input size=25 name="Company"></td></tr>

<tr><td>Phone:</td><td><input size=25 name="Phone"></td></tr>

<tr><td>Subscribe to<br> mailing list:</td><td><input type="radio" name="list" value="No"> No Thanks<br> <input type="radio" name="list" value="Yes" checked> Yes, keep me informed<br></td></tr>

<tr><td colspan=2>Message:</td></tr>

<tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr>

<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr>

<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr>

</table>

</form>

</body>

</html>



Explaining The Code 

 



The code on the last page collects seven pieces of data which we will 
explain here. It then submits the answers to a page called contact.php
which we will create next.

 

First we use the option feature to create a drop down menu,
allowing the user to direct their mail to different departments. Each
of these values is set to a different email address. When submitted the
form data will be directed to the appropriate email.



Next we collect information about the customer including their Name, Email, Company and Phone Number.

The user is then prompted to join our mailing list, and a radio button is set to default to "Yes".

Finally the user is given a chance to submit the body of their message in large text area.

This form could be copy-pasted into an existing page, or used as is.
Don't feel bound to using these categories, you can collect as much or
little information as you want using any HTML form input types.



Now we must create the PHP for the page contact.php, to collect the data and send it to the appropriate email.








 <?php 
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: noreply@YourCompany.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.YourDomain.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>




 Explaining The PHP:



The first three variables we assign in our program ($to, $from, and
$name) are all pulled directly from the form data using the $_REQUEST tag. We then define the from header, and a subject for our email (this can be anything you wish.)





Next we create an array;
the data on the left is the form fields and the data on the right is
the 'Human Friendly" label for each type of content. For example list is our mailing list field from our form, and Mailing List is its label. If you added other fields, or removed some from our example form, you must edit this array appropriately.





Next we define the message body. We use $body to first say what we are sending in the mail (We have received the following information) and then use a FOREACH loop to retrieve the data and its appropriate label from our array. We utilize sprintf() and its associated tags to make sure our data is in string format.



Next we define $headers2, $subject2 and $autoreply. These are the
values we will use in our mail to the customer to let them know their
form data has been sent to us. You can adjust these all as you see fit.




Finally we check that our required fields (Name and Email) were not left
blank before sending the email to our site staff and to the customer.





If this is successful, the user is directed (via the header location
tag) to a thank you page. If you prefer you can simply have it print
out a success message, similar to our error messages.

 

Friday, September 10, 2010

Hack Proof Your Website - eBooks

As you see, nowadays the hackers have ruined the internet business of website owners by hacking their websites and defacing them. It is true that they can do anything and can break any type of security, don't forget that Every Action Has An Equal Reaction. You can defeat them by updating your security.

Here are some useful books which can help you make your website's security a level up. Easy to read and follow books.



1. Hack Proofing XML K0.8.9







The World Wide Web Consortium's Extensible Markup
Language (XML) is quickly becoming the new standard for data formatting
and Internet development. XML is expected to be as important to the
future of the Web as HTML has been to the foundation of the Web, and has
proven itself to be the most common tool for all data manipulation and
data transmission. 


 




Hack Proofing XML provides readers with hands-on
instruction for how to secure the Web transmission and access of their
XML data. This book will also introduce database administrators, web
developers and web masters to ways they can use XML to secure other
applications and processes.






The first book to incorporate standards from both
the Security Services Markup Language (S2ML) and the Organization for
the Advancement of Structured Information Standards (OASIS) in one
comprehensive book



Covers the four primary security objectives: Confidentiality, Integrity, Authentication and Non-repudiation



Not only shows readers how to secure their XML data,
but describes how to provide enhanced security for a broader range of
applications and processes.










2. Hack Proofing Your Network, 2nd Ed.










A new edition the most popular Hack Proofing book around!



IT
professionals who want to run secure networks, or build secure software,
need to know about the methods of hackers. The second edition of the
best seller Hack Proofing Your Network, teaches about those topics,
including:



· The Politics, Laws of Security, Classes of Attack,
Methodology, Diffing, Decrypting, Brute Force, Unexpected Input, Buffer
Overrun, Sniffing, Session Hijacking, Spoofing, Server Holes, Client
Holes, Trojans and Viruses, Reporting Security Problems, Choosing Secure
Systems

The central idea of this book is that it's better for
you to find the holes in your network than it is for someone else to
find them, someone that would use them against you. The complete,
authoritative guide to protecting your Windows 2000 Network.

Updated coverage of an international bestseller and series flagship
Covers more methods of attack and hacker secrets



Interest in topic continues to grow - network architects, engineers and administrators continue to scramble for security books



Written by the former security manager for Sybase and an expert witness in the Kevin Mitnick trials
· A great addition to the bestselling "Hack Proofing..." series
· Windows 2000 sales have surpassed those of Windows NT

· Critical topic. The security of an organization's data and
communications is crucial to its survival and these topics are
notoriously difficult to grasp.














3. Hack Proofing Your Web Applications 






OPEC, Amazon, Yahoo! and E-bay: If these large, well-established and
security-conscious web sites have problems, how can anyone be safe? How
can any programmer expect to develop web applications that are secure?


Hack Proofing Your Web Applications is the only book specifically
written for application developers and webmasters who write programs
that are used on web sites. It covers Java applications, XML,
ColdFusion, and other database applications. Most hacking books focus on
catching the hackers once they've entered the site; this one shows
programmers how to design tight code that will deter hackers from the
word go.













4. Hack Proofing ColdFusion





The only way to stop a hacker is to think like one!ColdFusion is a Web
application development tool that allows programmers to quickly build
robust applications using server-side markup language. It is incredibly
popular and has both an established user base and a quickly growing
number of new adoptions. It has become the development environment of
choice for e-commerce sites and content sites where databases and
transactions are the most vulnerable and where security is of the utmost
importance.Several security concerns exist for ColdFusion due to its
unique approach of designing pages using dynamic-page templates rather
than static HTML documents. Because ColdFusion does not require that
developers have expertise in Visual Basic, Java and C++; Web
applications created using ColdFusion Markup language are vulnerable to a
variety of security breaches.Hack Proofing ColdFusion 5.0 is the
seventh edition in the popular Hack Proofing series and provides
developers with step-by-step instructions for developing secure web
applications.












Tuesday, September 7, 2010

Web Browser Cache!

One of the most frustrating things to happen when creating a web page is
when you can’t seem to get it to load on your website. You find a typo,
fix it and reupload, then when you view the page it’s still there. Or
you make a major change to the site and you can’t seem to see it when
you upload.






 





Web Caches and Browser Caches Affect How Your Page is Displayed





 


The most common reason for this is that the page is in your web browser
cache. The browser cache is a tool in all web browsers to help pages
load more quickly. The first time you load a web page, it is loaded
straight from the web server. Then, the browser saves a copy of the page
and all the images in a file on your machine. The next time you go to
that page, your browser opens the page from your hard drive rather than
the server.


The browser typically checks the server once per session. What this
means is that the first time you view your web page during a session it
will be saved on your computer. So, if you then find a typo and fix it
the upload may not display correctly.







How to Force Pages to Bypass the Web Cache





 


In order to force your browser to load a web page from the server rather
than the cache, you should hold down the shift key while you click on
the "Refresh" or "Reload" button. This tells the browser to ignore the
cache and download the page from the server directly.