PHP Code For Actor Questionnaire
This script is called actor-questionnaire.php
Scripts for Actor Questionnaire
The form action in HTML Code For Actor Questionnaire is the script on this page: actor-questionnaire.php. That script processes the data which the user enters in the form on the form page. The PHP script below will filter the data that gets entered.
First we define a regular expression pattern:
$pattern1 = '/[^A-Za-z0-9\\-\\.\\@\\_]/'. This will allow the legitimate characters found in emails and ensure there are no nasties in input. The replacement string ensures that all bad characters are dumped. Next, $pattern2 filters the visitor's name and dumps nasties or questionables. $pattern3 filters the visitor's age and the amount of pounds he can comfortably lift and dumps nasties or questionables. $pattern4 filters the visitor's fitness level, whether they have worked in front of a green (or blue) screen, whether they have a mustache, what days they are free to act, whether they are free to work a second afternoon, what race they are, whether they want to be the hero or villain, and whether they are skilled at applying their own makeup, and this pattern dumps nasties or questionables in input. $pattern5 filters the visitor's shoe size, dress size, and height and dumps nasties or questionables.
Incidentally, in the actor-questionnaire.html script, we use a lot of HTML filtering for data size and JavaScript filtering for size and characters in the input before the data ever encounters the actor-questionnaire.php script on this page. This is wise, because it can remind users of allowed characters when they put in illegal ones. Then the script can stick them right back into the input box where they are allowed to try again. (The focus() method is used to do this.) Users like this type of feedback, since if all filtering is done in PHP, bad data results in a restart—which users all HATE.
The data that has been entered is POSTed to this PHP script from the form. Then the single quotes and double quotes in the visitor's height input get replaced with ` and ``, respectively, since ` is safer than ' and `` is safer than " both of which are used in various hacker exploits. For the replacement task, we use the str_replace() function. Normally the quotes are dealt with by escaping before data goes into a MySQL database, using the mysql_real_escape_string() function, but since we are just sending data via email to an administrator, we just take an extra precaution out of the instinct of self preservation. Next the strip_tags() function knocks out tags in data. Then the preg_replace() function uses the 5 patterns to ensure the POSTed data is filtered.
Then we get to the email. We use the standard stuff here. The PHP variable $message gets this type of data: a variable, then a new line, then a label, etc. $N."\nHEIGHT: ".$H. . . . etc. is the way to do this. The entered email address becomes the "From" in the email which is now sent to the company administrator to process, making it the "To" when the administrator does a Reply.
We send the email using the standard form of email sending, which is mail($to, $subject, $message, $headers);. You'll want to change words like yoursite.com, and the link to index.html later to the words that apply in your situation. The user is told: "Message sent!" and sent to index.html, so you'll want that to be a real web page or you'll want to tweak it.
Everyday, somewhere between a gazillion and a humongousgazillion videos are watched on such sites as YouTube, which has somewhere between a gazillion and a humongousgazillion videos on its site. Someone had to make every one of them. None just appeared by magic. And all kinds of people are making indy films, reality shows, and the stuff that fills up those more obscure cable channels that few watch and fewer still care about (although most of us love the main cable and broadcast channels that give us lots of cool stuff). This means that an awful lot of people are using their local weekly newspapers, CraigsList, blogs, social networking, and so on to find people to come and be part of their gig, show, play, film, movie, video, and so on. When a person sees the ad for the gig, s/he has to respond somehow, and an HTML form is about as efficient as you can get.
When someone says they are 4 feet tall and you are doing a comedy about Munchkin-like Robin Hood characters sneaking into the warehouses of greedy corporations to steal stuff they later give to the needy, they become very interesting to you, if you are in charge of casting. (Yes, you may feel free to use this idea any way you want.) However, if you're doing a parody of the Boston GlobeTrotters, this person ("little people") will not get a second glace.
When people cast, there is no such thing as bigoted, racist, sexist, etc. You may describe needed characters of any type you want and of any look, race, sex, height, etc. you want. No one will bat an eye. You need to draw the line at "looking for ladies who will sleep with me," however, since most people know the difference between pandering and casting, so you may find yourself in the hoosegow if you persist with such ads!
Anyway, good luck with using this script, along with its actor-questionnaire.html counterpart, to find suitable actors. You may want to edit some of the questions in actor-questionnaire.html and therefore some of the filters in this actor-questionnaire.php script so they better suit your purposes.
This script is called actor-questionnaire.php
<?php
//Actor Questionnaire
$pattern1 = '/[^A-Za-z0-9\\-\\.\\@\\_]/';
$pattern2 = '/[^A-Za-z \\-]/';
$pattern3 = '/[^0-9]/';
$pattern4 = '/[^A-Za-z0-9 \\,]/';
$pattern5 = '/[^A-Za-z0-9 \\.\\/\\-\\`]/';
$replacement = '';
$N=$_POST['name'];
$E=$_POST['email'];
$H=$_POST['height'];
$H=str_replace("'", "`", $H);
$H=str_replace('"', '``', $H);
$F=$_POST['fitness'];
$A=$_POST['age'];
$G=$_POST['greenscreen'];
$FREE=$_POST['freedays'];
$S=$_POST['second'];
$R=$_POST['race'];
$M=$_POST['mustache'];
$L=$_POST['lift'];
$HERO=$_POST['hero'];
$DRESS=$_POST['dress'];
$SHOES=$_POST['shoes'];
$MAKEUP=$_POST['makeup'];
$N=strip_tags($N);
$N=preg_replace($pattern2, $replacement, $N);
$E=strip_tags($E);
$E=preg_replace($pattern1, $replacement, $E);
$H=strip_tags($H);
$H=preg_replace($pattern5, $replacement, $H);
$F=strip_tags($F);
$F=preg_replace($pattern4, $replacement, $F);
$A=strip_tags($A);
$A=preg_replace($pattern3, $replacement, $A);
$G=strip_tags($G);
$G=preg_replace($pattern4, $replacement, $G);
$FREE=strip_tags($FREE);
$FREE=preg_replace($pattern4, $replacement, $FREE);
$S=strip_tags($S);
$S=preg_replace($pattern4, $replacement, $S);
$R=strip_tags($R);
$R=preg_replace($pattern4, $replacement, $R);
$M=strip_tags($M);
$M=preg_replace($pattern4, $replacement, $M);
$L=strip_tags($L);
$L=preg_replace($pattern3, $replacement, $L);
$HERO=strip_tags($HERO);
$HERO=preg_replace($pattern4, $replacement, $HERO);
$DRESS=strip_tags($DRESS);
$DRESS=preg_replace($pattern5, $replacement, $DRESS);
$SHOES=strip_tags($SHOES);
$SHOES=preg_replace($pattern5, $replacement, $SHOES);
$MAKEUP=strip_tags($MAKEUP);
$MAKEUP=preg_replace($pattern4, $replacement, $MAKEUP);
$to = "info@yoursite.com";
$subject = "Actor Questionnaire";
$message = $N."\nHEIGHT: ".$H."\nFITNESS: ".$F."\nAGE: ".$A."\nGREENSCREEN: ".$G."\nFREE DAYS: ".$FREE."\nSECOND AFTERNOON: ".$S."\nRACE: ".$R."\nMUSTACHE: ".$M."\nLIFT (LBS.): ".$L."\nHERO OR VILLAIN: ".$HERO."\nDRESS SIZE: ".$DRESS."\nSHOE SIZE: ".$SHOES."\nMAKEUP SKILLS: ".$MAKEUP;
$headers = "From: ".$E;
$mail_sent = mail($to, $subject, $message, $headers);
if($mail_sent){echo '<SCRIPT LANGUAGE="JavaScript">alert("Message sent!");</script>';}
echo '<SCRIPT LANGUAGE="JavaScript">window.location = "index.html";</script>';
?>