WordPress redirect issue with php – Code Utility

Wordpress Redirect Issue With Php – Code Utility

i’ve some customers in my db. The PHP script choose the customers precisely, however redirect not working.

Please assist anybody my script is under:

if($sqlquery==1)
{
    $_SESSION'electronic mail'=$electronic mail;
    $_SESSION'password'=$password;
    wp_redirect( 'https://mcqpage.com/somepage', 301 );
    exit; 
} 
else
{
    header("location:http://www.mcqpage.com/index.php"); 
}  

my element are as comply with

login web page

<type onsubmit="return formValidator()" motion='https://mcqpage.com/connection/' methodology='submit'>
        <h2>Enter Your Details</h2><hr/>
        <label>Name :</label>
        <enter kind="text" title="addr1" id='addr' /><br />
        
        <label>Password :</label>
        <enter kind="password" title="password" id="password">
        
    
        
        <enter kind="submit" worth="Check Form"  />

connection web page

> insert_php

session_start();

if($_POST'addr1'!="" && $_POST'password'!=""){

session_start();

[email protected]_connect("") or
 mysql_error();

        if (!$connec) {

    die('Could not join: ' . mysql_error());

}

    $electronic mail=$_POST'addr1';

//echo"$email";

$password= $_POST'password');  

if ($electronic mail=="")
 {
    echo "Enter User Name.......";
 }

else


    $outcome = mysql_query("SELECT * FROM `database`.`desk` WHERE 

password='$password' and title="$email"");

    $information = mysql_num_rows($outcome);

 

    if($information==1)
      {
         $_SESSION'electronic mail'=$electronic mail;

          $_SESSION'password'=$password;

wp_redirect( 'https://mcqpage.com/web page', 301 );

 exit; 

      } 
    else
    {
        header("location:http://www.mcqpage.com/index.php"); 
    }  
 }
 
//connection closed
mysql_close ($connec);}
else{
        header("location:http://www.mcqpage.com/index.php"); 
}
/insert_php

@Nadav My error_log reveals the next error:

> 02-May-2017 07:29:06 UTC PHP Warning:  session_start(): Cannot ship session cookie - headers already despatched by (output began at /dwelling/mysite/public_html/wp/wp-includes/class.wp-styles.php:237) in /dwelling/mysite/public_html/wp/wp-content/plugins/insert-php/insert_php.php(47) : eval()'d code on line 2
> 
> 02-May-2017 07:29:06 UTC PHP Warning:  session_start(): Cannot ship session cache limiter - headers already despatched (output began at /dwelling/mysite/public_html/wp/wp-includes/class.wp-styles.php:237) in /dwelling/mysitec/public_html/wp/wp-content/plugins/insert-php/insert_php.php(47) : eval()'d code on line 2
> 
> 02-May-2017 07:29:06 UTC PHP Warning:  Cannot modify header data - headers already despatched by (output began at /dwelling/mysitec/public_html/wp/wp-includes/class.wp-styles.php:237) in /dwelling/mysite/public_html/wp/wp-content/plugins/insert-php/insert_php.php(47) : eval()'d code on line 25

,

please examine it if helpful for u

READ :  AcquireConnection method call to the connection manager failed with error code 0xC0202009

https://www.templatemonster.com/help/wordpress-how-to-create-a-redirect-from-a-home-page-to-any-url-using-the-php-redirect.html#gref

$location = get_site_url() . "/contact";
wp_redirect( $location, 301 );
exit;

,

Are you performing your redirect after the headers have already been despatched?
If so it won’t work. Please guarantee that your code is working earlier than the headers are despatched, ideally as a part of the template_redirect hook that WordPress affords.

If you aren’t certain the place your code is being loaded I recommend you incpsulate your code inside a perform that runs in the course of the template_redirect hook. For instance, you’ll be able to add the next to your theme’s features.php file:

perform handle_session_data()
{
  //Your code right here.
}
add_action( 'template_redirect', 'handle_session_data' );

,

the next code solved my drawback

`perform register_my_session()

{

if( !session_id() )

{

session_start();

}

}`
in perform.php

and begin the session with none error, for header, i used the java script redirect, this solved my drawback

Leave a Reply

Your email address will not be published. Required fields are marked *