FORUMS: list search recent posts

php blues. stumped on making a simple form

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Carl Sollenberger
php blues. stumped on making a simple form
on Feb 22, 2011 at 8:34:53 am

I am working on my own site and having trouble with a form I would like to implement.
On my contact page I have made a very simple form that would allow people to type in a message, hit send, and then have that message go to my email. Well... the form looks ok but does not work at all.

I have searched and read posts on the cow in an effort to not have to trouble anyone with a post, but am unable to resolve this problem.

I don't even know if the php page needs to have the same name as my form, but I suspect it might.

I downloaded a php script that I found on google and had no luck.
I get this error when trying to use the form on line:
Method Not Allowed
The requested method POST is not allowed for the URL /contact.html.


My form is named form1 and my php page is named form1formprocess.php
my site is westbrookadvertising.com


Thank you very much, Carl


Return to posts index

Mike Smith
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 9:11:55 am

You need to put the url of your php page in the form action property in your form. At present you have a blank in the quotes after action - as

<form action="" method="post" name="form1" id="form1">


<form action="PUT THE URL OF YOUR PHP SCRIPT HERE" method="post" name="form1" id="form1">


Return to posts index

Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 9:46:59 am

please forgive me, trying to understand.

I know where the form action is, but I'm not sure what the correct url would be.

My site is westbrookadvertising.com and my form is form1formprocess.php. so would the correct url be
http://westbrookadvertising.com/form1formprocess.php.html ?
That's what I put in and still no luck for what it's worth. And thank you very much for your help by the way.

Carl



Return to posts index


Mike Smith
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 2:08:50 pm

Sorry Carl

PHP is a server-side language - it all happens at the server, not in the browser. If a file has PHP in it and the server knows that, then before the web page is served a PHP interpreter on the server looks at the script in the PHP file, and, we hope, carries out the operations asked for, passing the results to the web server to include in the page supplied to the browser.

The usual way people let the server know what to do is to use a .php file extension = not with .html at the end.

So in your case you could try setting as your form action
http://westbrookadvertising.com/form1formprocess.php

and let us know what happens ?

All best

In fact I've just tried that, and your server has supplied me the raw php file, which is not good - a security risk for you.

OK it's not quite that bad, security wise, though you do have some PHP issues. Someone has replaced the open-angle-brackets < signs with the html entity '< " on your vital php opening tag and elsewhere, which looks the same over the web but does not work the same at the server end. I'm not sure I can offer a quick fix on this - your php page is a long way from what you need.





Return to posts index

Mike Smith
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 2:37:56 pm

Using what you have, you could try replacing your php file contents with these (save your originals somewhere as a backup) and be sure that your second and fourth EOD are the first and only things on their lines - no spaces before or after. This is my guess at what your script file was meant to look like ...

<?php

/* Email Variables */

$emailSubject = 'contactformprocess!';
$webMaster = 'westbroo@westbrookadvertising.com';


/* Data Variables */

$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];



$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>

Comments: $comments <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://westbrookadvertising.com/contact.html">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}

-->
</style&;gt;
</head>
<div >
<p > Put your message in here letting the sender
know the message has been successfully sent </p >
</div>
</body>
</html>
EOD;
echo "$theResults";
>


Return to posts index

Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 6:11:12 pm

wow thank you so much for all of your time. I used your code and still no luck - as well as the action script.
I can't thank you enough for your time, and I will keep plugging away at this. Kind of funny how complicated a simple form like this is turning out to be. I'm sure I've found a way to make it harder than it should be.

Thanks again! Greatly appreciated.



Return to posts index


Mike Smith
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 7:40:06 pm

Try putting a ? before the final close angle brackets so
?>
Try closing the title tag line with a </title> so

<title>sent message </title>

Try closing the inverted commas in the http meta refresh line so



And try closing the CLOSING style tag with a close angle bracket instead of the special & gt ; character, so
< /style >

there may be more little things I haven't spotted yet. If you want the message sent message to last longer before the page returns to your contact form increase the value in the meta http refresh to say 5

like

<meta http-equiv="refresh" content="5;URL=http://westbrookadvertising.com/contact.html" >


Return to posts index

Richard Williams
Re: php blues. stumped on making a simple form
on Feb 22, 2011 at 8:01:38 pm

Hi Carl/Mike

Carl, i helped someone in another forum with their PHP Script, and wrote out some explainations of what we are doing and why in the code, the post is here and it might help you understand a little better hopefully and get your form working.

Also, in the Dreamweaver forum under FAQ's link, Abraham has a very simple form submission PHP script which again you could follow and try out then work on that...

Hope this helps.

Richard Williams
p.s. Please remember to rate our post replies and tick if solved. Also, please remember that we here are NOT employed by Adobe, we do this out of love and fun, so its always nice to recieve a Please and Thank You! :o)


Return to posts index

Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 2:18:48 am

Thanks a lot to both of you fellas for your time and help!
My brain is turning in to mush at this point : )

I might just take a break from this, because no matter what I try I'm having zero luck. I'm sure a lot of it if not all of it is that I'm fairly new to php and code....

I've read all of your excellent posts and many others, I'm just not able to get this darn form going.

AT this point I've scrapped all of my php pages because they are just getting hashed and rehashed.

I just need a fresh start.

A big thanks again guys.



Return to posts index


Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 3:30:01 am

Well I checked and my server handles php.... am I suposed to load some php code directly in to my server? Or is the php page in my root folder all I need.


Return to posts index

Fernando Mol
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 4:08:38 am

Create a new file and name it:

phpinfo.php

The content of such file should be:

<?php
phpinfo();
?>


Save and upload to your site. If you can open it then you have PHP and the file will display all the php info on your server.

I have to add, many hosting services provide their own code for contact forms, for security reasons. Ask them.


Return to posts index

Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 4:41:43 am

I think you are right about their own code. Now I need to figure out how to implement it.

The server uses php 5.2.14

There is an addon called FormMail.pl I installed it and then I copied the code and put it on a clean phpsheet and now when I hit my submit key it takes me to the code lol : )
I guess that at least means my form is conecting to the php page... the php page just isn't working right...

Getting there - slow but sure.
Thanks!



Return to posts index


Fernando Mol
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 5:20:32 am

Usually you need to point to that code in the form action. Also, you'll need to tweak the code a little, placing your email info and thank you page.

Sometimes you are requested to use an email of the same domain. You can't send it to a hotmail or gmail account, but you'll need to read the instructions on that FormMail code. Is usually commented.

I hope this helps


Return to posts index

Carl Sollenberger
Re: php blues. stumped on making a simple form
on Feb 23, 2011 at 7:13:14 am

Yes indeed Fernando, I think you are correct. I will try to get a hold of my provider to see what I may be missing. The email is my websites built in email, so I'm all set there. I'm hoping they will be able to tell me what I'm missing in how I'm adjusting the form. At this point I think it's a small detail and because I'm new I am simply overlooking something that an experienced web designer would catch without much trouble.

Once I am sure I understand what my service provider requires I will simply rebuild the form and start over. Should take less than a few hours and give me a chance to practice new skills.

You guys have all been very great! Thank you so much. I will post once I make progress.



Return to posts index

Mike Smith
Re: php blues. stumped on making a simple form
on Feb 24, 2011 at 8:52:09 am

Yes, I'm sure Richard and Fernando have a better approach with going for a different form, and best one supplied and approved by your ISP.

The one we were looking (too hastily,on my part) was worryingly lacking in basic security, and we would have been having to think about cleansing user input, checking the domain calling the script, and hiding it from direct access over the web, once we'd got it working !


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]