Webmaster Forum

Webmaster Forum (http://www.v7n.com/forums/index.php)
-   Coding Forum (http://www.v7n.com/forums/forumdisplay.php?f=16)
-   -   Help Figuring Out Contact Form (http://www.v7n.com/forums/showthread.php?t=249257)

baby.hack 05-04-2011 08:59 AM

Help Figuring Out Contact Form
 
Hi,
I'm new to these forums. I have some basic webdesign and programming knowledge, but I'm still not really familiar with php or js. I'm a bit of a newbie.

I friend has asked me to help with a site they run, and the contact form they are using needs to have the "to" email changed.

Perhaps someone here might be able to point me in the right direction?

The page is http://www.parkdaleliberty.com/show_info.php?page_id=8

The form is in a .php file, the contents of which are printed in the page source from that file.

So far I'm not sure what I should be looking for.

I'm familiar with forms of the <form method="POST" action="somefile.php"> variety, but this seems different. What happens when the submit button is pressed? Where should I be looking to find the code that processes and sends the form (ie: if(isset($_POST['submit'])) { .....} )

I feel like this should be obvious, so forgive me if it is.

nemrod 05-04-2011 10:05 AM

First of all, welcome to the forums! Hope you have a good stay. :)

Now, as for your problem, it's impossible to say without seeing the PHP code. The form should send to the same page since there is no action attribute, so take a look at the source code of it.

diondevelopment 05-04-2011 03:38 PM

When the submit button is pressed, it sends POST variables server-side so that the values can then be used through whatever programming language they are using.

Through this code they are sending the email, using the POST variables.

bwclapp 05-04-2011 09:57 PM

your form action is set to somefile.php (action="somefile.php")

the somefile.php will have to get the variables somehow (done by using $_POST[])

for example.. your somefile.php will contain at the top

Code:

$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$age = $_POST['age'];

then you would be able to do anything you wanted with them on the somefile.php script, whether it be emailing the form or posting them on the page.

Code:

echo $firstname; // Displays the first name from the form that was submitted.
Hope this helps...

nemrod 05-04-2011 10:57 PM

Quote:

Originally Posted by bwclapp (Post 1655445)
your form action is set to somefile.php (action="somefile.php")

the somefile.php will have to get the variables somehow (done by using $_POST[])

for example.. your somefile.php will contain at the top

Code:

$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$age = $_POST['age'];

then you would be able to do anything you wanted with them on the somefile.php script, whether it be emailing the form or posting them on the page.

Code:

echo $firstname; // Displays the first name from the form that was submitted.
Hope this helps...

Indeed, but it would help even more if you had taken a look at the page first. There is no action attribute on the form tag, for example, but as I said that means it should post to itself. :)

bwclapp 05-05-2011 12:05 AM

If you are making it submit to itself you may have to put the action as show_info.php although I'm not sure how this would work with it having a GET variable (?page_id=8) in the URL. I believe you can only use either GET or POST, but not both. I'm pretty sure since you are using GET for the page id, you will have to pass the information along using the GET method for the users information as well.

then your url would look something like ?page_id=8&name=$name&email=$email&phone=$phone$.. .etc so forth and so on.

You would then, instead of using POST at the top of that file, use GET to get the form data from the browsers url. GET forms are a little bit trickier than POST forms... I'm tired and loopy right now, but google should help you out from here.

Another alternative is to make the form POST to a separate .php file that opens up in a fixed size window with no scrollbars with text and maybe an image saying something like "Your information has been sent. We will be in touch soon" (you get the point)

Although, to answer the question directly, I don't think you can use POST on this page since it is already using GET for the page_id.

nemrod 05-05-2011 12:16 AM

Quote:

Originally Posted by bwclapp (Post 1655601)
If you are making it submit to itself you may have to put the action as show_info.php although I'm not sure how this would work with it having a GET variable (?page_id=8) in the URL. I believe you can only use either GET or POST, but not both. I'm pretty sure since you are using GET for the page id, you will have to pass the information along using the GET method for the users information as well.

then your url would look something like ?page_id=8&name=$name&email=$email&phone=$phone$.. .etc so forth and so on.

You would then, instead of using POST at the top of that file, use GET to get the form data from the browsers url. GET forms are a little bit trickier than POST forms... I'm tired and loopy right now, but google should help you out from here.

Another alternative is to make the form POST to a separate .php file that opens up in a fixed size window with no scrollbars with text and maybe an image saying something like "Your information has been sent. We will be in touch soon" (you get the point)

Although, to answer the question directly, I don't think you can use POST on this page since it is already using GET for the page_id.

You can send POST-data to a page with querystrings.

baby.hack 05-06-2011 06:25 AM

You guys are awesome. Why is that?
I hadn't even thought to look at show_info for the contact form processing. I was looking at the page with id 8, at the contactform.php file with the form in it, at the php file that is one of the includes in contactform.php. But of course, if the form is posting to itself, and the page is show_info.php... well, *facepalm*.

Now I have another issue. Apparently the reason the address needed to be changed is because the form was generating spam. I figured i would post that a separate issue: http://www.v7n.com/forums/coding-for...ml#post1656053


All times are GMT -7. The time now is 05:29 AM.

3.8.7