send to a link

Issues related to hyperlinks and web site navigation.
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/links.html
Post Reply
Joan Ferrer
 
 
Posts: 112
Joined: Sat Apr 25, 2020 5:17 pm
Contact:

send to a link

Post 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
User avatar
Pablo
 
Posts: 22422
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: send to a link

Post 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.
Joan Ferrer
 
 
Posts: 112
Joined: Sat Apr 25, 2020 5:17 pm
Contact:

Re: send to a link

Post 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
User avatar
Pablo
 
Posts: 22422
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: send to a link

Post 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.
Joan Ferrer
 
 
Posts: 112
Joined: Sat Apr 25, 2020 5:17 pm
Contact:

Re: send to a link

Post by Joan Ferrer »

OK, thank you very much for everything
Tnk's
Post Reply