So, I have a HTML form and I need to send it's value as a parameter to a php function, but I also need a different value, that's not even inside the HTML.
For example:
<form action="methods.php" method="register">
<input type="text" placeholder="EventID">
<input type="submit" value="Register">
</form>
This form would get the event id and send it as a parameter to register the user into the event. But I need to send the user as a parameter also (function register($user, $eventid)
) and I have no idea on how to do so.
I did find some similar things around here, but they were related to POST and GET and I'm not sure they work for me and I could not understand how to use in them in my case, so if anyone could help me out, pleaaaaaase, i'd be really thankful
you can use hidden field or you can use session or cookie for user
if you use cookie or session then there is not need to pass it as parameter its a global variable so you can access its value at any page directly, you just need to store value to it and access it any where in your project.
Its very simple you just need to take care of few things.
1: every input field should have a name.
2: set form method either GET(to send values visible in the url) or POST(to send data without showing in the url)
3: on methods.php receive form data if send via GET then $_GET['input_field_name'] or via POST then $_POST['input_field_name']
Look for the explanation in comments below:
What do you think?