Link to home
Start Free TrialLog in
Avatar of cycledude
cycledudeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

wordpress contact form

Hi

I am trying to develop a contact form on a wordpress page, but I dont want to use any plugins, just my own php/html.

All I want to do it post the form contents back to the same page, so that I can process the form using php (which is in the same page as the form) and either display errors or redirect to a thank you page. simples...

or maybe not...

The page displays perfectly, but whenever I click 'send' it returns back to my blog page, but the url is for the contact page?? kind of weird thing going on there...

I have the following form declaration:

<form id='contactform' method='post' action=''>


Avatar of joeypolice
joeypolice
Flag of United States of America image

May I ask why you are not wanting to use any plugins?  This is a great one which can be customized easily.

http://wordpress.org/extend/plugins/contact-form-7/

-Joey
Avatar of cycledude

ASKER

Reason is I have my own script with jquery and php to handle the processing, which I like more...

I have used contact for 7, and dont really like it...
You could try this: http://www.phpeasystep.com/phptu/8.html

Or, I have a simple PHP script that I have used several times which is easy to implement.  I would be happy to email it to you.
just to clarify,

you have a contact form on a page like www.yourblog.com/contact

you submit the page to itself

after submit it displays www.yourblog.com/contact in the url but is showing the page from www.yourblog.com

SOLUTION
Avatar of joeypolice
joeypolice
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@jrm213jrm213:

you got it mate, spot on


This is the HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Form</title>
</head>

<body>
<form action="contact.php" method="post">
	Your name<br>
    <input type="text" name="cf_name"><br>
	Your e-mail<br>
    <input type="text" name="cf_email"><br>
	Message<br>
    <textarea name="cf_message"></textarea><br>
	<input type="submit" value="Send">
	<input type="reset" value="Clear">
</form>
</body>
</html>

Open in new window

@joeypolice

Thanks for the script mate, but like I say I have a pretty comprehensive one I developed myself, which uses jquery and php... I am more than happy with it, just getting wordpress to post to the same page is my problem.

Sorry, I misunderstood.  :)
@joeypolice

No problem, thanks for your help ;o)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@jrm213jrm213:

Thanks, tried it but it is the same....

this link has some info, but tried that and I get no page content other than the header when the form returns...

http://wordpress.org/support/topic/bug-found-forms-posting-to-itself

@jrm213jrm213:

I am developing the page directly in the template, not in wordpress at all..

In wordpress I have a page called contact which is using the the template that I am manipulating in my dev tool

I have basically taken my contact from from my existing (non wordpress) website and pasted the code into the template-file... maybe this can't be done this way?

weird, this simple code works

<?php echo 'We have got: ' . $_POST['f1'] . ''; ?>
<form action="" method="POST">
<input type="text" name="f1" value="test"/>
<input type="submit" name="submit" value="Submit"/>
</form>

Open in new window

ok I am narrowing it down to an error in the php somewhere...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what do you mean it is throwing the page out?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
script would have worked had I included the inStr function!

doh!