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.
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
$pattern1 = '/[^A-Za-z0-9\\-\\.\\@\\_]/';
$pattern2 = '/[^A-Za-z \\-]/';
$pattern3 = '/[^0-9]/';
$pattern4 = '/[^A-Za-z0-9 \\,]/';
$pattern5 = '/[^A-Za-z0-9 \\.\\/\\-\\`]/';
$replacement = '';
$H=str_replace("'", "`", $H);
$H=str_replace('"', '``', $H);
$N=preg_replace($pattern2, $replacement, $N);
$E=preg_replace($pattern1, $replacement, $E);
$H=preg_replace($pattern5, $replacement, $H);
$F=preg_replace($pattern4, $replacement, $F);
$A=preg_replace($pattern3, $replacement, $A);
$G=preg_replace($pattern4, $replacement, $G);
$FREE=preg_replace($pattern4, $replacement, $FREE);
$S=preg_replace($pattern4, $replacement, $S);
$R=preg_replace($pattern4, $replacement, $R);
$M=preg_replace($pattern4, $replacement, $M);
$L=preg_replace($pattern3, $replacement, $L);
$HERO=preg_replace($pattern4, $replacement, $HERO);
$DRESS=preg_replace($pattern5, $replacement, $DRESS);
$SHOES=preg_replace($pattern5, $replacement, $SHOES);
$MAKEUP=preg_replace($pattern4, $replacement, $MAKEUP);
$to = "firstname.lastname@example.org";
$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);