Hi there!
I know this questions might be a bit 'general' and not necessarily WP-related, but I still hope to get some advice. I am having a form in my sidebar and the appropriate PHP code to process the form in the same file. Here is how it looks:
Form
<form method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>">
<input type="hidden" name="name" id="name" value="<?php echo $current_user->display_name; ?>">
<input type="hidden" name="email" id="email" value="<?php echo $current_user->user_email; ?>">
<textarea name="message" id="message" placeholder="Your message..."></textarea>
<input type="submit" name="submit" class="button" id="submit" value="Send" />
<div class="clear"></div>
</form>
PHP-Code
<?php
if($_POST) {
$to = '###';
$subject = $name . 'sent you a message!';
$message = $_POST['message'];
$name = $_POST['name'];
$from_email = $_POST['email'];
$headers = 'From: ' . $name . ' < ' . $from_email . ' >';
$mail = wp_mail( $to, $subject, $message, $headers );
}
?>
On successful submit I would now like to stay on the same page and have, for instance, the textarea field be replaced with a 'successful icon'.
Any idea how I can achieve that?
Many thanks,
do77
P.S. I have read endless tuts about jQuery, Ajax etc. and have implemented it like 10 times but it would never work for me.