Jump to content

on submit....


ajicles

Recommended Posts

I am trying to make my website submit a file when the submit button is pressed. I tried to use isset but when I press submit it doesn't work.

 

This is just an example of when I am trying to do:

<?php

if (isset($_POST['submit'])) {
echo "clicked";
}
else
{
echo "not_clicked";
}

?>

<form  id="myform" enctype="multipart/form-data" action="test.php" method="POST">
<input type="submit" value="Upload" />

</form>

Link to comment
Share on other sites

You have no form element named 'submit'.

 

<form  id="myform" enctype="multipart/form-data" action="test.php" method="POST">
  <input type="hidden" name="submit">
  <input type="submit" value="Upload" />
</form>

Link to comment
Share on other sites

I am trying to make my website submit a file when the submit button is pressed. I tried to use isset but when I press submit it doesn't work.

 

This is just an example of when I am trying to do:

<?php

if (isset($_POST['submit'])) {
echo "clicked";
}
else
{
echo "not_clicked";
}

?>

<form  id="myform" enctype="multipart/form-data" action="test.php" method="POST">
<input type="submit" value="Upload" />

</form>

 

Do something following.

<?php
if (isset($_POST['SubmitMe']) && $_POST['SubmitMe'] == 1){
echo "clicked";
} else{
echo "not_clicked";
}
?>

<form  id="myform" enctype="multipart/form-data" action="test.php" method="POST">
<input type="hidden" name="SubmitMe" value="1">
<input type="submit" value="Upload" />
</form>

Link to comment
Share on other sites

or just do <input type="submit" name="submit" value="Upload" /> so you wont have to add a hidden line :)

 

Some browser won't send that information. It's safe to use the hidden form or check for a field you know exists.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.