Give help. Get help.
Hi, I am trying to create a self referencing contact form in wordpress but I can’t work out what to put in the post-action bit. I have tried everything I can think of like
<form action="<?php bloginfo('url')?>/contact-php
and things but everything comes back to page net found, what am I missing?
Are you sure the page exists? Also, you need to have permalinks set up and working, cause this is a permalink you’re referring to. The way you do it now, the output would be:
http://example.com/contact-php
But if you don’t have permalinks set up, it won’t work. Check whether or not they are set up and see if this page really exists. Otherwise, try referencing it to some page you do know exists for sure, and add the extension to it, like this:
Or like
<?php bloginfo('url')?>/about.php
Can you please post your full code of the form? There might an error in your code, as I’ve just tried it with the following code, which works just fine:
<form action="<?php bloginfo('url')?>/?page_id=2"><br />
<input type="submit" /><br />
</form>
<code></code>
In the code you submitted in your first post, there is no ” at the end, maybe thats why it doesn’t work? Anyway, like I said, post your full code so we can see whats going on.
Here is the code:
if(isset($_POST)){<br />
$emailFrom = strip_tags($_POST);<br />
$emailTo = "matt@digital-spoon.co.uk";<br />
$subject = "Contact Form Submission";<br />
<br />
$name = strip_tags($_POST);<br />
$city = strip_tags($_POST);<br />
$email = strip_tags($_POST);<br />
$message = strip_tags(stripslashes($_POST));<br />
<br />
$body = "Name: ".$name."n";<br />
$body .= "City: ".$city."n";<br />
$body .= "Email: ".$email."n";<br />
$body .= "Message: ".$message."n";<br />
<br />
$headers = "From: ".$emailFrom."n";<br />
$headers .= "Reply-To:".$email."n";<br />
<br />
if(isset($_POST)){<br />
$success = mail($emailTo, $subject, $body, $headers);<br />
if ($success){<br />
echo '<p class="yay">All is well, your e–mail has been sent.</p>';<br />
}<br />
} else {<br />
echo '<p class="oops">Something went wrong</p>';<br />
}<br />
} else {<br />
?><br />
<br />
<form action="<?php bloginfo('url'); ?>/contact-php/" method="post" id="contact" name="contact"><br />
<fieldset><br />
<legend>Contact form</legend><br />
<label for="name">Name</label><br />
<input type="text" id="name" name="name" class="required" minlength="2"/><br />
<br />
<label for="city">City</label><br />
<input type="text" id="city" name="city" class="required" minlength="2"/><br />
<br />
<label for="email">E–mail</label><br />
<input type="text" id="email" name="email" class="required email"/><br />
<br />
<label for="message">Message</label><br />
<textarea id="message" name="message" cols="50" rows="10" class="required"></textarea><br />
<br />
<br />
<input type="submit" id="submit" name="submit" value="Send!" /><br />
</fieldset><br />
</form>
<code></code>
Cheers,
Matt
http://www.digital-spoon.co.uk/contact-php/ is the site where I am testing on,
Cheers,
Matt
In case anyone finds this via search…
I encountered the same issue, and it has to do with the form field names. I believe WordPress is interpereting either a POST or GET key value of ‘name’ as a post name to determine what wordpress page to show (resulting in a 404 error in most cases).
To verify if this is the issue, put in the slug of a post (like ‘contact-php’) in the name field, submit the form and see what happens (If it is a valid page/post slug, it should take you to that page).
Laters,
Stephen
You must be logged in to reply to this topic.