Forum Moderators: phranque

Message Too Old, No Replies

Bacis form wont submit

it just refreshes the page when i submit

         

casey133

10:31 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



I am making a very basic contact form using Dreamweaver MX 2004 and php. When i try to insert a form field in design view nothing even happens! I can switch to code view and when i insert it by hand and then preview in browser and try to submit it it just refreshes the whole page. What causes this and how can I fix it? I have seen this on a number of templates that I have downloaded as well but am not sure why?

<form action="http://www.mysite.com/test.php" method="post">Form content goes here</form>

I thought it might be because I was trying to test the HTML file on my local computer but thats not it, when I try on different website that I did it works fine... need help here guys.

Any help would be greatful,

Thanks

roldar

12:39 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I'm not familiar with Dreamweaver, but here are a few ideas of mine:

1) Do you have a form page and a separate form processing page? Is file.php the name of the page with the form on it, or is that a separate page which processes the contents of the form?

2) You say you're testing this on your home computer. Is the form file a .php file? If so, do you have PHP installed and working on your home computer? If not, this could prevent it from working correctly.

Here's how I go about making a contact form:

form.html --> this page contains the form where they enter their contact info & question/comment. The form has action='process_form.php' as its target.

process_form.php --> this page gets the POST data, mail()s the contact to me, outputs "Thank you for your question/comment/etc."

You could make a single .php page with an IF statement to determine whether to display the form or process the form, but I wouldn't recommend it.

casey133

12:50 am on Jan 20, 2005 (gmt 0)

10+ Year Member



Thanks fir the reply... here is how i have it set up:

the page the form goes on, lets say its called contact.htm

i just have a standalone php file called "form.php" for example

i just set the action to form.php ... i dont have the php file on my local system, i have it on my web server which does support php, but even if i do upload everything, it still just refreshes like it does on my local system. i am really lost on this one.

roldar

12:51 am on Jan 20, 2005 (gmt 0)

10+ Year Member



Here's a basic contact form & form processor.

-------------

form.html (this is where they enter the contact info & question/comment)

<body>
<form name="contact_form" method="POST" action="form_processor.php">
<p>Enter your email address: <input type="text" name="email_address"></p>
<p>Enter your question/comment: <textarea name="question_comment" cols="20" rows="20"></textarea>
<p align="center"><input type="submit" value="Submit"></p>
</form>
</body>

---------------

form_processor.php (this receives all the data from the form and does what you want with it. In this case, it emails it to you)

<body>
<?php
$email_address=$_POST['email_address'];
$question_comment=$_POST['question_comment'];

$email_from="From: ".$email_address;
$email_subject="Contact form email";
mail("youremail@yourdomain.com", $email_subject, $question_comment, $email_address);
?>

<p>Thank you for your question/comment.</p>
</body>

------------

[edited by: roldar at 12:56 am (utc) on Jan. 20, 2005]

roldar

12:54 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I'm not sure why it would refresh the contact form page. As far as I know that wouldn't have anything to do with support of php or not. Look over your contact form and make sure you have a submit button set up properly and that the action is set properly. If you leave out a " around the action, or if you put your submit button on the outside of the form it could cause problems.

ControlEngineer

4:13 am on Jan 20, 2005 (gmt 0)

10+ Year Member



Shouldn't there be a header or some such function in form_processor.php to send the user to a "the form has been submitted" page?

coho75

4:31 am on Jan 20, 2005 (gmt 0)

10+ Year Member



Have you tried using an absolute link to the form processing file?

casey133

4:35 am on Jan 20, 2005 (gmt 0)

10+ Year Member



no i havnt tried that, think that would make a difference? i have a makeshift solution right now, the page that didnt work int he first place, i now have it as a sized popup page... so when the user clicks "click here for free trial classes" it brings up a sized page with nothing but the form inside a table, which tells me it has to be something in the code thats not making it work... not sure yet tho.