Jump to content

Php navigation


colap
 Share

Recommended Posts

        <form>
            <input name="ins" type="submit" value="INSERT">
            <input name="upt" type="submit" value="UPDATE">
            <input name="del" type="submit" value="DELETE">
        </form>

Link to comment
Share on other sites

You need to link the form to your PHP file, and then check to see which submit button was pressed using a pretty simple series of IF statements... for example:

 

HTML:

 

        <form action="yourpage.php" action="post">
            <input name="ins" type="submit" value="INSERT">
            <input name="upt" type="submit" value="UPDATE">
            <input name="del" type="submit" value="DELETE">
        </form>

 

"yourpage.php":

 

if (isset($_POST['ins']))
{
    echo 'INSERT...';
}
elseif (isset($_POST['upt']))
{
    echo 'UPDATE...';
}
elseif (isset($_POST['del']))
{
    echo 'DELETE...';
}

Link to comment
Share on other sites

You need to link the form to your PHP file, and then check to see which submit button was pressed using a pretty simple series of IF statements... for example:

 

HTML:

 

        <form action="yourpage.php" action="post">
            <input name="ins" type="submit" value="INSERT">
            <input name="upt" type="submit" value="UPDATE">
            <input name="del" type="submit" value="DELETE">
        </form>

 

"yourpage.php":

 

if (isset($_POST['ins']))
{
    echo 'INSERT...';
}
elseif (isset($_POST['upt']))
{
    echo 'UPDATE...';
}
elseif (isset($_POST['del']))
{
    echo 'DELETE...';
}

No.

If i click insert button,it will redirect to insert.php file,similarly

update button-->update.php

delete button -->delete.php

 

I don't want to display the yourpage.php file for the click event of these three buttons.

I'm trying "different page display for different button's click event".

Link to comment
Share on other sites

Well then you'll need 3 different forms, or to use JavaScript. JS however, as mentioned before, is un-reliable.

 

Going with a similar idea to mine though; you could link to the other page, decide on the action you need to take, and then redirect as appropriate. Look into header for that.

Link to comment
Share on other sites

Well then you'll need 3 different forms, or to use JavaScript. JS however, as mentioned before, is un-reliable.

 

Going with a similar idea to mine though; you could link to the other page, decide on the action you need to take, and then redirect as appropriate. Look into header for that.

Why isn't javascript reliable?

I have also tried this.But it's not working.

        <form >
            <input name="ins" type="submit"
                value="INSERT" onclick="location.href='byte.html'">
            <input name="upt" type="submit" value="UPDATE">
            <input name="del" type="submit" value="DELETE">
        </form>

Link to comment
Share on other sites

It works.But how would i use header() here instead of action=""?

        <form action="byte.html">
            <input name="ins" type="submit" value="INSERT">
        </form>
        <form action="stp.php">
            <input name="upt" type="submit" value="UPDATE">
        </form>

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.