![]() |
|
|
PHP form | |||
|
Penguins on toast
Posts: 1,182
Name: carl
Location: UK
|
I have managed to get XAMP working (thanks Andrei) so I can test PHP scripts and the form I asked about previously doesn't seem to work.
I am getting errors Quote:
The form code is HTML Code:
<form id="form1" name="form1" method="post" action="sendmail.php"> <label for="Name">Full Name</label> <input type="text" name="Name" id="Name" /> <label for="PhoneNo">Home Phone</label> <input type="text" name="PhoneNo" id="PhoneNo" /> <label for="MobileNo">Mobile Phone</label> <input type="text" name="MobileNo" id="MobileNo" /> <label for="Email">Email Address</label> <input type="text" name="Email" id="Email" /> <label for="PropVal">Property Value <br /> <span class="Formsmallprint">If secured finance is required</span></label> <input type="text" name="PropVal" id="PropVal" /> <label for="LoanAmount">Amount Required<br /> <span class="Formsmallprint">If secured finance is required</span></label> <input type="text" name="LoanAmount" id="LoanAmount" /> <label for="debtHelp">Total value of Debt<br /> <span class="Formsmallprint">If debt help is required</span></label> <input type="text" name="debtHelp" id="debtHelp" /> <label for="FinType">How can we help</label> <select name="FinType" id="FinType"> <option selected="selected">Please Select</option> <option value="mortgage">Mortgage</option> <option value="remortgage">Remortgage</option> <option value="secured">Secured Loan</option> <option value="debtconsol">Debt Consolidation</option> <option value="debt_man">Debt Management</option> <option value="iva">IVA</option> <option value="BTL">Buy to Let</option> <option value="commercial">Commercial</option> <option value="other">Other</option> </select> <label for="callaT">Best Time to Call</label> <select name="callaT" id="callaT"> <option>Please Select</option> <option value="morning">Morning</option> <option value="afternoon">Afternoon</option> <option value="evening">Evening</option> <option value="any">Any time</option> </select> <input type="submit" name="submit" id="submit" value="Call me back" /> <a href="javascript:newwindow()" ><br /> Data Protection Statement</a> </form> The PHP is PHP Code:
Quote:
and Quote:
Can anyone shed any light on this please.
__________________
Lifes as good as you make it... Last edited by bakerc : 05-08-2008 at 08:34 PM. |
|||
|
|
|
| Sponsored Links (We share ad revenue): |
|
|
Re: PHP form |
|
Junior Talker
Posts: 2
|
You need an SMTP (outgoing mail) server set up to use PHP's mail() function.
|
|
|
|
|
|
Re: PHP form | ||
|
Penguins on toast
Posts: 1,182
Name: carl
Location: UK
|
I should have posted this as the sendmain.php file, sorry
PHP Code:
Quote:
Quote:
The outgoing SMTP server port is 25, and I dont know what is meant by can't modify header. I thought the header line would redirect the users browser to the thank you page. Could these errors have somthing to do with how I have XAMP set up? Again - thanks for any help
__________________
Lifes as good as you make it... Last edited by bakerc : 05-08-2008 at 09:55 PM. |
||
|
|
|
|
|
Re: PHP form |
|
Ultra Talker
Latest Blog Post:
Web Development Business Tips Posts: 437
|
You might be having a bit of a problem with your predefined variables. Generally speaking, for a registration form like this, you're almost always going to want to use $_POST. Right now you have $_REQUEST, which means that the information could come from either the URL or from the form. I would recommend always using either $_POST or $_GET and never using $_REQUEST. It isn't very often that you aren't going to know where you are getting your data from. In the case of the second script you posted, you might be getting some of your errors because you are using the $_GET instead of the $_POST (because your form's action is set to post).
As a security matter, you should also check each input to make sure it's the kind of data you want. In this form, someone could type all sorts of information that doesn't match the field in which it was typed. For instance, without any sort of validation, I could type in "green bean" for an email address and this script wouldn't know any better. It becomes even more of a security problem if you were using this form to load information into the database. Using SQL injection, a malicious user could erase or manipulate your database at will. It's a good habit to always validate user entered data from the beginning. Never trust user input. For your header problems, take a look at this page. It seems like it's a fairly common problem. As you're learning PHP, I'd recommend several things. If you get an error and can't figure out what's causing it, paste the error code, minus the file path and line number into Google. I've found a lot of fixes that way. Another suggestion is to keep a dictionary of your error code messages and what you did to fix them. You won't need it after a while, but it can be a handy reference. Finally, the documentation at php.net is invaluable once you learn how to use it. The comments after the documentation can sometimes be even more helpful. For your mailing problem, I'm not quite sure what the problem is because I've never compiled PHP yet. You might have to enable the mail server in your php.ini file. A quick search should bring something useful, but if not, look at the docs for XAMP and PHP. Hope that helped. |
|
|
|
|
|
Re: PHP form | |
|
Ultra Talker
Latest Blog Post:
Web Development Business Tips Posts: 437
|
Looking at it again, I can see why you're probably having problems. Look at the way you're trying to create $content. After every line, you're ending it with a semicolon, but you aren't concatenating the values like you did with $header. If you remove all your semicolons for $content (except for the last one), I have a feeling it might work, solving both the headers already sent error and the email error.
Quote:
|
|
|
|
|
|
|
Re: PHP form |
|
Ultra Talker
Latest Blog Post:
Web Development Business Tips Posts: 437
|
You still have to remove the last double quote from this line:
PHP Code:
By the way, if you're looking for good tutorials online, I'd recommend http://www.tizag.com/. W3schools is good too. If you want a book, I'd recommend anything by Larry Ullman. I'm pretty sure you'll pick it up quickly because you seem really open to learning. Last edited by VirtuosiMedia : 05-09-2008 at 12:02 PM. |
|
|
|