0

I use a method="post" form and made a test script.php to check my variables and this is what I get:

array(0) {
}
array(0) {
}
array(0) {
}
Array ( ) GET

this is my html:

<form id="contacts-form" method="post" action="contact.php" 
enctype="multipart/form-data">
<fieldset>
<div class="field"><input type="text" name="f_name"/></div>
<div class="field"><input type="text" name="f_email"/></div>
<div class="field"><input type="text" name="f_phone"/></div>
<div class="field"><textarea name="f_message" cols="1" rows="1"></textarea></div>
<div class="wrapper">
<a href="contact.php" class="link2"
onclick="document.getElementById('contacts-form').submit()" name="subjoin"> 
<span>
<span>Send Your   Message</span>
</span>
</a>
</div>
</fieldset>
</form>

here's my contact.php script:

<?php
$mypostdata = file("php://input");
print "<pre>";
var_dump($_POST);
var_dump($mypostdata);
var_dump($_GET);
print "</pre>";
print_r($_POST);
print_r($_SERVER['REQUEST_METHOD']);
1
  • You have a link that submits the form, with just some text inside of it...? Ever hear of <input type=submit>? :P Commented May 12, 2013 at 5:46

1 Answer 1

1

Your mistake is in your link:

<a href="#" class="link2" onclick="document.getElementById('contacts-form').submit(); return false;" name="subjoin"> 

Should work because a normal link just links zu contact.php and does not submit the form.

Sign up to request clarification or add additional context in comments.

14 Comments

thank you so much :D I wasted 5 days of my project trying to figure it out, really you saved my day!
@SherifRiad: If you'd use a submit button for this as the gods intended, you wouldn't have wasted so much time. You wouldn't even have had to script anything. Just saying. :)
yeah right, but I had to stick to my design in the website with button look a links
yes I do, but that's the way I started it on many pages, and it was great.. simply it's: shit happens! anyway I'll consider using buttons later on as you suggested :)
@cHao you can style buttons, but it works slightly different in different browsers because buttons seem to have the old IE-box-modell
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.