0

Ok so I have a very basic form, that used to work.

<form action="index.php#enquiry" method="post" id="quickform">
  <input type="hidden" name="submit" value="yes">
  <label class="labels">Name</label>
  <input type="text" id="reqname" name="reqname" /><br/>
  <label class="labels">Tel</label>
  <input type="text" class="validate[required] input" name="num" id="valiphone" /><br/>
  <label class="labels">Email</label>
  <input type="email" class="custom[email] input" name="useremail" id="valiemail" />       
  <label class="labels">Enquiry</label>
  <textarea id="textarea" rows="7" name="messtxt" class="validate[required]"></textarea>
  <button type="submit" style="border: 0; background: transparent" id="sendButton" >
    <img src="images/send.png" alt="submit" />
  </button>
</form>

This self submits, and when reloaded should hit a simple php if statement:

if (isset($_POST['submit'])) {

Do thing A

}else{

Do thing B

}

Thing A never gets executed.

I know it self submits and hits the PHP because I can echo a string

I've done this a million times, and I am 100% sure this script worked a couple of days ago, so unless i've typod something and can't see it by accident. Is there something that could of gone wrong where pages don't post? server wise or anything? I've noticed similar problems with an upload script I had.

25
  • You have unclosed textarea tag
    – Atber
    May 29, 2013 at 0:01
  • was a copy and paste error, its closed on the actual script and corrected the question
    – AltTab
    May 29, 2013 at 0:02
  • 3
    try running a var_dump() on $_POST and see what you get. That'll at least tell you if nothing's getting POSTED at all or if something else is wrong.
    – Funktr0n
    May 29, 2013 at 0:06
  • I've been thinking that so many times and it always turns out to be a mistake i made somewhere anyhow. Try and give os some of your php code.
    – jah
    May 29, 2013 at 0:08
  • class="validate[required] input" seems weird to me. In PHP, [] is treated as an array input. I for one, don't understand how your script works. Some explanation would be nice. As is your index.php#enquiry; most bizarre. May 29, 2013 at 0:08

2 Answers 2

1

Check your .htaccess file. Might be the culprit.

0
1

PHP $_POST assumes that the data entered in the brackets is the name of the element. In your case you have not named your submit button "submit", which is what you are telling PHP...
Simply change the button to this:

<button type="submit" style="border: 0; background: transparent" id="sendButton" name="submit">
    <img src="images/send.png" alt="submit" />
</button>

I just added name="submit". You also should get rid of your hidden input named submit. This should solve the problem!

1
  • Read my edit... I cover that too... Now it seems like a different problem. Thx for pointing that out!
    – pattyd
    May 29, 2013 at 0:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.