-3

I'm trying to learn PHP, and to do so im trying to create a code to register new products, i've made an loggin access where the person to do so needs to be connected, so inside of the cpanel I did differents sections, like add client, add product...

So i did an index in the _cpanel folde where i have my main html and to not repeat the same html i put an include inside this index so i can call others php files inside.

I dont know if its correctly to do like this BUT, as i said Im new at programming..

But everything works pretty good, until i need to call my post in my url..

like.. to add a new product i need to go to :

localhost -> connect... to go to localhost/_cpanel

if i click in add a new produt, i go to localhost/_cpanel/?page=folder/addnewproduct.php

and inside this php file i put a form with an action="?go=addnewproduct"

so, i did everything to put all the info in my db, but when i submit it goes to

localhost/_cpanel/?go=addnewproduct and nothing happens..

i tried to change the action like action="folder/?page=addnewproduct.php&?go=addnewproduct" but it doesnt work either.

BUT i made it works changing to action"folder/addnewproduct.php?go=newproduct

but to do so i need to go to "addnewproduct.php", and this page only is an included page inside my index..

i could call back to the index page after adding a new product, so that it doesnt show this page only, but when posting it loads fast to the page and after than it go back to my _cpanel.

i tried to find solutions but, didnt find... i think its just a problem with the way i put it in my action, maybe theres a way to do it and i dont know it yet.

ceejayoz
  • 165,698
  • 38
  • 268
  • 341
J. Afonso
  • 1
  • 1

1 Answers1

0

I don't think I get what you're wanting exactly, but here you go:

If you're trying to redirect the request, you may just use the header function as follows:

header('Location: target/url.php');

If you want to make a external post request with php, you may use curl, as suggested here:

PHP + curl, HTTP POST sample code?

Community
  • 1
  • 1
CarlosCarucce
  • 2,874
  • 1
  • 25
  • 43