- This topic is empty.
-
AuthorPosts
-
September 17, 2010 at 5:59 pm #30280
matt25
ParticipantHi, 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?
September 18, 2010 at 1:49 pm #79546Bob
MemberAre 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
September 20, 2010 at 1:41 pm #79582matt25
ParticipantThe page defiantly exists, on the permalinks section in the pages it is ‘/contact-php’ and when I go to the page directly it goes there
Cheers,
MattSeptember 20, 2010 at 3:35 pm #79586Bob
MemberCan 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.
September 20, 2010 at 3:50 pm #79588matt25
ParticipantHere is the code:
if(isset($_POST)){<br />
$emailFrom = strip_tags($_POST);<br />
$emailTo = "[email protected]";<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,
MattSeptember 20, 2010 at 4:22 pm #79590Bob
MemberI can’t really see an error there, do you have a live example?
Also, try testing it locally with MAMP or something like that, to see if that works. Might be something with your hosting.
September 20, 2010 at 5:04 pm #79591matt25
Participanthttp://www.digital-spoon.co.uk/contact-php/ is the site where I am testing on,
Cheers,
MattSeptember 23, 2010 at 6:05 am #79214willB
MemberHave you tried just using:
January 5, 2013 at 6:10 pm #119936sspann
MemberIn 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,
StephenMay 6, 2013 at 4:12 pm #134280 -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.