Page 1 of 1

10 to 20 User Inputs to Process in PHP

Posted: Fri Mar 28, 2008 1:04 pm
by Rajudk
I just put my step in PHP.I aim to master it very soon and help others freely.I searched for a Guide to teach me.I bought a book,but the Form Processing Chapters are very limited.So I came here.

My Question: How to process 10 to 20 User inputs(HTML Form inputs) in PHP to send email.(10-20 User Inputs to My Email)
For eg.
Name:
Email:
Tel:
Address1:
Address2:
etc

Pls guide me.I only get free Feedback form for free.I want to add more to it.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Fri Mar 28, 2008 1:17 pm
by hawleyjr
Step 1: create HTML Form
Step 2: Create PHP page to process form. Use either $_POST or $_GET to retrieve the values of the form.
Step 3: Use PHP's native mail() function to send the email.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Fri Mar 28, 2008 1:33 pm
by Rajudk
With examples of my user inputs please.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Sat Mar 29, 2008 5:44 pm
by micknc
If you are looking for the code I would suggest searching for a tutorial. I tried "php mail form tutorial" and got plenty.

This one seemed very simple and would include the framework to get you going:

http://www.kirupa.com/forum/showthread.php?t=17313

The tutorial is self posting but I would adapt it like hawleyjr said to go from the form page to a process page.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Sat Mar 29, 2008 11:16 pm
by Rajudk
Thanks Kirupa.com.
Can you suggest me of a Secure PHP to email Hot Script that is compitabble with Php v.5.2.3.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Mon Mar 31, 2008 3:45 pm
by micknc
I use SwiftMailer. It is compatible and can use (among others) SMTP.

http://www.swiftmailer.org/

Re: 10 to 20 User Inputs to Process in PHP

Posted: Tue Apr 01, 2008 1:48 pm
by Rajudk
It did not work,a little guidance please.Write here by changing the codes below-
Can any one make the following a valid php5 form processing:-

<?php

$_POST['fullname']
$_POST['email']
$_POST['telephone']
$_POST['mobile']
$_POST['plan']
$_POST['agreement'] // user input will be yes or no


$to = $_POST[email];
$sublect = "We'll reply very soon";
$msg = "Dear: " . $_POST[fullname] . " " $_POST[email] . ",\n\n";
$msg .= "We have received details from you."

$mailheaders = "From: Registration Page <aaaa@ppp.com>;
$mailheaders .= "Reply - To: dddd@eee.com";

mail($to, $subject, $msg, $mailheaders);


?>

Re: 10 to 20 User Inputs to Process in PHP

Posted: Tue Apr 01, 2008 2:14 pm
by John Cartwright

Code: Select all

$msg .= "We have received details from you."
You are missing a semi colon. Disreguarding the security implications of your script (using unsanitized input) and potentially firing off E_NOTICE errors from undefined variables, and E_NOTICE undefined constants from not quoting array keys, things look ok.

Try putting error_reporting(E_ALL); at the top of your script and see the magic happen :)

However, I would have to kindly ask you to stop asking people to do the work for you. This includes PM's.

Re: 10 to 20 User Inputs to Process in PHP

Posted: Tue Apr 01, 2008 2:53 pm
by Rajudk
See there is Parse error: syntax error,
unexpected T_STRING in /nnnn/hhhh/public_html/present.php
on line 9 (which is underlined).

Any other errors and Security issue?

<?php

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email']))
{ header( "Location: $formurl="http://www.pppp.com/form5.html" ); exit ;
}
if (empty($name) || empty($email) || empty($comments)) { header(
"Location: $errorurl="http://www.pppp.com/error.html" ); exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header(
"Location: $errorurl="http://www.pppp.com/error.html" ); exit ;
}
if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments );
}
$messageproper = "This message was sent from:\n" . "$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" . "Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto='bikri@pppp.com', $subject="Feedback Form", $messageproper, "From: \"$name\"
<$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
$headersep . "X-Mailer:php 5.2.3" );
header( "Location: $thankyouurl="http://www.pppp.com/success.html" );
exit ;

?>

Re: 10 to 20 User Inputs to Process in PHP

Posted: Tue Apr 01, 2008 3:39 pm
by EverLearning

Code: Select all

 
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email']))
{ header( "Location: $formurl="http://www.pppp.com/form5.html" ); exit ;
}
if (empty($name) || empty($email) || empty($comments)) { header(
"Location: $errorurl="http://www.pppp.com/error.html" ); exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header(
"Location: $errorurl="http://www.pppp.com/error.html" ); exit ;
}
if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments );
}
$messageproper = "This message was sent from:\n" . "$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" . "Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto='bikri@pppp.com', $subject="Feedback Form", $messageproper, "From: \"$name\"
<$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
$headersep . "X-Mailer:php 5.2.3" );
header( "Location: $thankyouurl="http://www.pppp.com/success.html" );
exit ;
If you had put your code in proper tags(like above), you would have seen the problem yourself.
Which is, in case you still don't see it, in your header() arguments.

So ...
1. If you're going to use double quotes (") in a string that is double quoted you have to escape them (\"), or simpler, use single quotes('). That unexpected string error happened because PHP parser encountered http://www.pppp.com/form5.html after the end of the string.
2. You can't define variables in strings like you tried.

Code: Select all

header( "Location: $formurl="http://www.pppp.com/form5.html" ); exit ;
should be

Code: Select all

$formurl="http://www.pppp.com/form5.html";
header( "Location: $formurl" );
exit;
You really should read more on PHP basics. Read around the forums, use Google.