Jump to content

Request URL to show a message ??


spacepoet

Recommended Posts

Hello:

 

I want to show a message only if the user gets to the page by another page

(Is a "Create New Section" page that transfers to the Edit page).

 

I thought this might work:

<?php
if ($_REQUEST['URL'] == 'a_websiteDataAdd.php')
echo "<span class=\"textError\">Section successfully created!</span>"
?>

 

but it does not ...

 

Any ideas on this?

Link to comment
Share on other sites

First off $_REQUEST is just a way to grab the variable regardless of whether it's get or post.

 

Second, your code that you posted 'will' work if it's done correctly.  On the page that shows the link "Create New Section"

set the URL as a get parameter. 

<a href='page.php?URL=correcturl">Create Section</a>

Then in your section code page add this

<?php
if ($_REQUEST['URL'] == 'correcturl') {
      echo "<span class=\"textError\">Section successfully created!</span>";
}
?>

 

Of course you have to be aware that just echoing out success doesn't mean it does anything with the database...you actually have to handle that part.

Link to comment
Share on other sites

Hi:

 

Forgot completely about getting a parameter!

 

One small issue (but it's not a dealbreaker, but would be nice to clean-up):

 

a_websiteDataAdd.php:

header("Location: a_websiteData.php?id=id&URL=a_websiteDataAdd.php");

 

Goes to:

a_websiteData.php:

<?php
if ($_REQUEST['URL'] == 'a_websiteDataAdd.php') {
      echo "<span class=\"textError\">Section successfully created!</span>";
}
?>

 

This does work fine, but since it's now on the page used to edit and add content, when the form gets POST, it will write both messages:

 

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
echo "<span class=\"textError\">Section successfully updated!</span>"
?>

<?php
if ($_REQUEST['URL'] == 'a_websiteDataAdd.php') {
      echo "<span class=\"textError\">Section successfully created!</span>";
}
?>

 

The URL looks like:

a_websiteData.php?id=id&URL=a_websiteDataAdd.php

 

Any way to TRIM or REPLACE the "&URL=a_websiteDataAdd.php" off when the form gets submitted:

<form method="post" action="<?php echo $PHP_SELF;?>">
<input type="hidden" name="POSTBACK" value="EDIT">
<input type="hidden" name="id" value="<?php echo $id; ?>">

...

</form>

 

??

 

 

 

 

 

 

 

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.