Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JelvisChan

macrumors member
Original poster
Jan 9, 2009
77
0
PHP on iWeb '08​

Does anyone know a way to use php on iWeb '08?

Here are the codes I am trying to process:

HTML:
HTML:
<form method="post" action="contact.php">
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form>

-and-

PHP:
PHP:
<?php
$to = "you@yoursite.com";
$subject = "Join Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>


How, on iWeb, is there a way so that I can put the HTML inside a snippet, and when you click submit query, it redirects to the thank you, good job, or whatever page? This would be EXTREMELY helpful!

Help if you can! Thanks.
 
Where are you going to be hosting this?

If you're using MobileMe, it can't be done because it doesn't support PHP.

If you're using another web host, FTP in to the server and add the file (contact.php) to the same directory as the file with the form. iWeb isn't made to support PHP so it requires some work.

Also, I'm not sure, but I think you should change the $_REQUEST's to $_POST
 
Also, I'm not sure, but I think you should change the $_REQUEST's to $_POST

Yes, it is always "best practice" to use $_POST if form method=post or $_GET if form method=get in PHP. If you're wondering $_REQUEST has been around since PHP 4.1.0 and is a superglobal like the other two discussed here, meaning its value is available in all memory scopes and you don't need to import it via the "global" command in functions/classes. It also contains $_POST, $_GET and $COOKIE superglobals as well. Developers using PHP4 often got lazy and used this convenient superglobal for obvious reasons since in most php.ini default configurations it was enabled. It's still available in PHP5 but usually disabled in the config for security reasons. And of course its use in the OP's code is very insecure - vulnerabilities include XSS (cross site scripting) and injection, for the record.

-jim
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.