Jump to content

Php navigation


colap

Recommended Posts

I don't understand.

your buttons will resolve a link in plain html anyways.

 

If you want to redirect from php for any reason, try:

 

//Some condition here, like is the guy logged in? 
   header("Location:http//address.com");

 

link : http://ca3.php.net/manual/en/function.header.php

Link to comment
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931541
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
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931584
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
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931594
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
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931606
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
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931620
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
https://forums.phpfreaks.com/topic/176693-php-navigation/#findComment-931628
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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