vendredi 25 novembre 2016

php - if user is coming from X page

I have an index.php page containing all recipes, where each recipe has an anchor tag to add ingredients. When you click it takes you to http://localhost/recipes_book/add_ingredients.php?id=4, the id being the recipe id. You can add ingredients only from a dropdown list, if the ingredient you want to add is not within the list, you need to add it as ingredient in the database on new_ingredient.php page. After the ingredient is registered, it will appear in the dropdown list to add it as ingredient for each recipe.

My question is.... can I redirect the user to the recipe they were adding the ingredient in the first place after the ingredient has been added? I mean... the ingredients can also be added "generally" from index.php, and it takes you to the same new_ingredient.php page.

Is there any way I can say "if user was coming from http://localhost/recipes_book/add_ingredients.php?id=X, redirect to the same page in success of adding the ingredient, but if the user clicked add ingredient from index.php, I don't want to redirect them to any recipe page.

Am I explaining myself any clear at all? I am not placing any code because it is irrelevant here, the only think I want to know if there is any php function to say "if the user came from this page".

Thank you!

Aucun commentaire:

Enregistrer un commentaire