PDA

View Full Version : Using PHP on iWeb V2.0 on Leopard 10.5




JelvisChan
Jan 11, 2009, 02:48 AM
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:
<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
$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.



mikes63737
Jan 13, 2009, 07:18 PM
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

SrWebDeveloper
Jan 15, 2009, 10:18 AM
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

angelwatt
Jan 15, 2009, 01:00 PM
Duplicate thread: see here. (http://forums.macrumors.com/showthread.php?t=632241)