Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

How Would I Get an Echo'd Button to Redirect?

PHP Code

<?php 
function CallButton() {
    global 
$con;
    
$email = $_POST['email']; 
    
$email = mysqli_real_escape_string($con, $email);
    
$at = "@";
    
$pos = strpos($email, $at);
    if(
$pos===false) {
        echo 
"Please enter a valid email address";
    }
    else {
    
    echo 
"<Thank you. Please click the button below to coninue.<br><br><input type='submit' name='openOffer' value='Proceed' class='btn btn-primary'>";
}
    } 

I'm trying to get it to redirect to a CPA offer but the button just disappears. My database gets updated first but I can't get it to redirect.
Resident Writer for MyGamer.Com and Horrify.Net
I think your "<" at the beginning can do that!
(Jan 23, 2019 08:52 AM)I337 Wrote:  I think your "<" at the beginning can do that!

How though and any idea why the button disappears?
Resident Writer for MyGamer.Com and Horrify.Net
As for the button, check to verify it is being outputted, using Chrome inspector tools or something. Input tags must be closed with a forward slash and a right arrow (Idk the legitimate name) [Eg. /> ]

PHP has native functions to validate an email. I could literally just enter a @ into your little input and it would be valid. Use the functions. Please FOR MY SAKE do not use "im following a tutorial" as an excuse to perform lousy validations.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
PHP Code

<?php 
function CallButton()
{
    if(
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
    {
        echo 
'Thank you. Please click the button below to coninue.<br><br><input type="button" name="openOffer" value="Proceed" class="btn btn-primary" onClick="window.location='."'offer.php'".'">';
    }
    else
    {
        echo 
"Please enter a valid email address";
    }
} 
You see, Doctor, God didn't kill that little girl. Fate didn't butcher her and destiny didn't feed her to those dogs.
If God saw what any of us did that night he didn't seem to mind. From then on I knew... God doesn't make the world this way.
We do.
Code
global $con;

For future references, be careful when using global variables like this, it isn't the best practice, it's really easy for you to make changes without actually knowing where changes are being made. A better approach would be to pass the connection object around in the parameters, use the singleton pattern or use dependency injection.
(Jan 23, 2019 09:31 AM)Nachfolger Wrote:  As for the button, check to verify it is being outputted, using Chrome inspector tools or something. Input tags must be closed with a forward slash and a right arrow (Idk the legitimate name) [Eg. /> ]

PHP has native functions to validate an email. I could literally just enter a @ into your little input and it would be valid. Use the functions. Please FOR MY SAKE do not use "im following a tutorial" as an excuse to perform lousy validations.

I will look for a comprehensive list of all PHP functions. To be fair, I am just doing this from what I have learned so far. It's nothing to serious and was just having a mess around. I have decided to actually use it so will use the function.

(Jan 23, 2019 10:20 AM)Squito Wrote:  
PHP Code

<?php 
function CallButton()
{
    if(
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
    {
        echo 
'Thank you. Please click the button below to coninue.<br><br><input type="button" name="openOffer" value="Proceed" class="btn btn-primary" onClick="window.location='."'offer.php'".'">';
    }
    else
    {
        echo 
"Please enter a valid email address";
    }
} 

Awesome. Thanks, man.

(Jan 23, 2019 10:59 AM)+Haze Wrote:  
Code
global $con;

For future references, be careful when using global variables like this, it isn't the best practice, it's really easy for you to make changes without actually knowing where changes are being made. A better approach would be to pass the connection object around in the parameters, use the singleton pattern or use dependency injection.

Appreciate the heads-up.
Resident Writer for MyGamer.Com and Horrify.Net


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by killaxiaJun 24, 2021 02:42 PM 16 456 Jun 24, 2021 02:42 PM
Last Post: BuyingSpade
[PHP] by blackcoder00Feb 17, 2019 04:13 PM 1 166 Feb 17, 2019 04:13 PM
Last Post: Abruptum
[PHP] by blackcoder00Jan 10, 2019 06:22 PM 4 196 Jan 10, 2019 06:22 PM
Last Post: Disease