-2
<?php
    $_SESSION['sdate'] = $_POST['sdate'];
    $_SESSION['edate'] = $_POST['edate'];
    //assigning the variables in sessions


    $sdate = $_POST['sdate'];
    $edate = $_POST['edate'];

    $query = mysqli_query($conn,"INSERT INTO subscribers (username, password, sdate, edate, day ) 
            VALUES ('".$_SESSION['username']."','".$_SESSION[md5(password-1)]."','".$sdate."', '".$edate."', 50");
    //inserting into the table subscribers
                    ''
    if ($conn -> $query === TRUE) {
        $_SESSION['message'] = "subscription Complete!";
        header("location: ../register/error.php");
        //success location
    }
    else{
      $_SESSION['message'] = "subscription  Failed!";
        header("location: ../register/error.php");
    }
?>

I have been trying to insert session variables in the table but its bringing out a parse error :

'Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\bennett\subscription\function.php on line 15'

Mickaël Leger
  • 3,426
  • 2
  • 17
  • 36

2 Answers2

0

put $_SESSION[md5(password-1)] in a variable and why are you passing -1 with the password?

just do like this

$password = $_SESSION["password"];

$query = mysqli_query($conn,"INSERT INTO subscribers (username, password, sdate, edate, day ) 
    VALUES ('".$_SESSION['username']."','".md5($password)."','".$sdate."', '".$edate."', 50");

Hope this helps.

Dilip Gupta
  • 124
  • 1
  • 10
0
$query = mysqli_query($conn,"INSERT INTO subscribers (username, password, sdate, edate, day ) 
            VALUES ('".$_SESSION['username']."','".$_SESSION[md5(password-1)]."','".$sdate."', '".$edate."', 50");
    //inserting into the table subscribers
                    ''

these two single-quotes before your if making code parsing to throw error

undrown
  • 32
  • 6