shams Posted August 12, 2018 Share Posted August 12, 2018 Hi, The index.php calling the check.php with the form action="check.php" and passing the value of $cat_id and $subcat to the check .php from the two drop down menu, i i included the other page post.php with require_once in the check.php, the post.php gets the value of $subcat from the index.php as condition and prints the full row of msqyl table subcategory, my question is how to pass the values of post.php in the variable $_POST to the check.php as you see below it prints the row but not with the $_POST variables, this is the output of all pages in the check.php: cat_id =4 subcategory=user@gmail.com user=user@gmail.com passw=aaaaaaa server=smtp.gmail.com Notice: Undefined index: user in /home/user/www/user.be.eu.org/check.php on line 5 Notice: Undefined index: passw in /home/user/www/user.be.eu.org/check.php on line 6 Notice: Undefined index: server in /home/user/www/user.be.eu.org/check.php on line 7 Value of $cat = 4 Value of $subcat = user@gmail.com Value of $user = Value of $passw = Value of $server = This is check.php: <?Php require_once 'post.php'; $cat= $_POST['cat']; $subcat= $_POST['subcat']; $from = $_POST['from']; $user = $_POST['user']; $passw = $_POST['passw']; $server = $_POST['server']; print_r($row); echo "Value of \$cat = $cat <br>Value of \$subcat = $subcat <br> Value of \$from = $from <br>Value of \$user = $user <br>Value of \$passw = $passw <br>Value of \$server = $server"; ?> this is post.php: <?php set_exception_handler(function($e) { error_log($e->getMessage()); exit('Something weird happened'); //something a user can understand }); error_reporting(E_ALL); ini_set('display_errors', '1'); $host = 'localhost'; $db = 'mail'; $user = 'root'; $pass = 'root'; $charset = 'utf8mb4'; $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; $pdo = new PDO("mysql:host=$host;dbname=$db;charset=$charset", $user, $pass, $options); ///// session_start(); $subcat=$_POST['subcat']; // select a particular user by id $stmt = $pdo->prepare("SELECT * FROM subcategory WHERE subcategory=?"); $stmt->execute([$subcat]); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ('cat_id =' . $row['cat_id'] . "\r\n" . 'subcategory=' . $row['subcategory']. "\r\n". 'user=' . $row['user'] . "\r\n". 'passw=' . $row['passw']. "\r\n". 'server=' . $row['server'] . '<br />'); } ?> <!DOCTYPE html> <html> <head></head> <body> <br /> <div class="container"> <div class="row"> <div class="col-md-8" style="margin:0 auto; float:none;"> <br /> <form action = "" method = 'post'> <input type="hidden" name="from" value="<?php echo $_POST['subcategory']; ?>" /> <input type="hidden" name="user" value="<?php echo $_POST['user']; ?>" /> <input type="hidden" name="passw" value="<?php echo $_POST['passw']; ?>" /> <input type="hidden" name="server" value="<?php echo $_POST['server']; ?>" /> </form> </div> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
shams Posted August 12, 2018 Author Share Posted August 12, 2018 Problem solved with this modified post.php: $pdo = new PDO("mysql:host=$host;dbname=$db;charset=$charset", $user, $pass, $options); ///// session_start(); $subcat=$_POST['subcat']; $stmt = $pdo->prepare("SELECT * FROM subcategory WHERE subcategory=?"); $stmt->execute([$subcat]); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $cat = $row['cat_id']; $from = $row['subcategory']; $user = $row['user']; $passw= $row['passw']; $server = $row['server']; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.