Page 1 of 1
send to a link
Posted: Wed Aug 16, 2023 3:39 pm
by Joan Ferrer
Good afternoon
My intention is for the customer to enter their phone number in an "editbox", and with a button send the customer to a folder (already created) with their phone number, I've tried and I don't know how to do it.
Thank you
Re: send to a link
Posted: Wed Aug 16, 2023 3:50 pm
by Pablo
There is no standard solution for this, because it's very specific.
But this may work:
1. Create a form with an editbox and submit button
2. Set the action to
Code: Select all
<?php echo basename(__FILE__); ?>"
3. Add this code to the start of the Page HTML:
Code: Select all
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Get the entered user name from the form
$userName = $_POST['username'];
// Define an array of user names and corresponding folder paths
$userFolders = array(
'user1' => 'path/to/user1/folder',
'user2' => 'path/to/user2/folder',
// Add more user names and folder paths as needed
);
// Check if the entered user name exists in the array
if (array_key_exists($userName, $userFolders)) {
// Redirect the user to the corresponding folder
$folderPath = $userFolders[$userName];
header("Location: $folderPath");
exit;
} else {
// User name not found, redirect back to the form
header("Location: index.html");
exit;
}
}
?>
Note: I did not try this myselfthis, it is just suggestion. You may need to tweak the code to make it work for you
Or else take a look at the login tools. Which also have a 'redirect' option.
Re: send to a link
Posted: Thu Aug 17, 2023 6:45 am
by Joan Ferrer
Good morning
It works perfectly, thank you very much.
I'm not a programmer, can it be simplified?
Enter user in "editbox" and send, if user exists, direct to a previously created folder, if that folder does not exist, direct to error page.
Greetings
Re: send to a link
Posted: Thu Aug 17, 2023 7:54 am
by Pablo
If you want different behavior then you will need to update the script yourself. This was just to help you in the right direction.
Unfortunately, I cannot teach you how to program.
Re: send to a link
Posted: Thu Aug 17, 2023 9:00 am
by Joan Ferrer
OK, thank you very much for everything
Tnk's