Jump to content

shams

Members
  • Content count

    68
  • Joined

  • Last visited

Community Reputation

0 Neutral

About shams

  • Rank
    Regular Member

Profile Information

  • Gender
    Male
  1. shams

    php code problem from command line?

    i am running ubuntu 18.04 and the packages php-apcu php-apcu-bc are installed, these php codes working fine from the web browsers. should i install the apcu from github or it's sufficient?
  2. I need to run getmail with two php codes in a loop, i tried to run all these from the web browser but the php code cannot start the getmail i use the exec, shell_exec and system, now i decided to run these code from the gnome terminal, but i get the problem with the one of php code not running from the command line , this one is not running: <?php $val = apc_fetch('id'); $id=$val + 1; apc_store('id', $id, 0); $var = apc_fetch('id'); echo $var ?> the command i am running the php code is #php -f /home/user/wwww/example.net/apc.php any help please?
  3. shams

    problem running program with exec()?

    The original code is with the closing quote , mistake is in the post i forget to put the closing qoute: <?php system('/home/user/.getmail/getmail.sh'); ?>
  4. shams

    problem running program with exec()?

    This is the code i am trying to start the getmail from the php code in the ubuntu 18.04, getmail.sh cat start the getmail from the gnome terminal but from php code bellow it cannot start the getmail: <?php system('/home/user/.getmail/getmail.sh); ?>
  5. shams

    problem running program with exec()?

    Thanks for reply i test the code it runs the bash scripts, i created test.sh file with the content "this is a test file", and run with the code: <?php system('/home/user/tmp/test.sh'); ?> The code printed the file to the browser successfully, but cannot start the linux applications like getmail and i tested for the filezilla with the code: <?php sysetm('/usr/bin/filezilla'); ?> how to start the getmail with php?
  6. I want to run the getmail from php code, this is the php code but it is not running the getmail: <?php chdir('/home/user/.getmail'); exec('./getmail.sh'); ?> getmail.sh and gmail-file are inside the '/home/user/.getmail' directory, i also tried the shell_exec() but not run the program, this is the getmail.sh code: #!/bin/sh /usr/bin/getmail --rcfile gmail-file
  7. 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']; }
  8. 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>
  9. Hi, This is a code dd.php with two drop down list options, when select the value from the first drop down it retrieves the related values from the column subcategory from the second table subcategory and prents only these two columns: Value of $cat = 2 Value of $subcat = user@gmx.ca My question is how to pass the value of $subcat to the query below in the same dd.php page and prints the full row of the table subcategory which has more 4 columns: SELECT * FROM subcategory WHERE subcategory=?; this is dd.php: <?php require 'config.php'; // Database connection //////// End of connecting to database //////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Multiple drop down list box from plus2net</title> <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='dd.php?cat=' + val ; } </script> </head> <body> <?Php @$cat=$_GET['cat']; // Use this line or below line if register_global is off if(strlen($cat) > 0 and !is_numeric($cat)){ // to check if $cat is numeric data or not. echo "Data Error"; exit; } ///////// Getting the data from Mysql table for first list box////////// $quer2="SELECT DISTINCT category,cat_id FROM category order by category"; ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($cat) and strlen($cat) > 0){ $quer="SELECT DISTINCT * FROM subcategory where cat_id=$cat order by subcategory"; }else{$quer="SELECT DISTINCT * FROM subcategory order by subcategory"; } ////////// end of query for second subcategory drop down list box /////////////////////////// echo "<form method=post name=f1 action='dd-check.php'>"; /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; foreach ($dbo->query($quer2) as $noticia2) { if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";} else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat'><option value=''>Select one</option>"; foreach ($dbo->query($quer) as $noticia) { echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>"; } echo "</select>"; ////////////////// This will end the second drop down list /////////// //// Add your other form fields as needed here///// echo "<input type=submit value=Submit>"; echo "</form>"; while ($row = $quer->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 />'); } ?> <br><br> <a href=dd.php>Reset and start again</a> <br><br> <center><a href='http://www.plus2net.com' rel="nofollow">PHP SQL HTML free tutorials and scripts</a></center> </body> </html>
  10. shams

    Problem sending mail with PHPmailer?

    The problem solved with the: $mail->Subject = $_POST['subject']; $mail->Body = $_POST['message']; $mail->AltBody = $_POST['message'];
  11. shams

    Problem sending mail with PHPmailer?

    Thanks for reply, please can tell me how to post the Subject and Body in variables from the form to the mailer.php?
  12. shams

    Problem sending mail with PHPmailer?

    Hi i did some modification in form index.php and rename to index.html now it is some thing improved now the only problem is with the Subject and Body i can send the message with: $mail->Subject = 'test message'; $mail->Body = 'test message from phpmailer'; But with the variable from the form : $mail->Subject($Subject); $mail->Body($Message); Get this error: [04-Aug-2018 04:50:09 UTC] Call to undefined method PHPMailer\PHPMailer\PHPMailer::Subject() any help please?
  13. I want to send mail with phpmailer using form index.php and mailer.php the variables from $_POST is working, the "print_r($_POST);" prints all the values of variables from the form to the mailer.php: Array ( [name] => shamsurrahman [from] => shams@example.com [email] => shams@example.net [cc] => [bcc] => [subject] => test message [message] => test message from phpmailer. [submit] => Submit ) Something weird happened The mail cannot send and in the /var/log/php.log these are errors: [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: error in /var/www/pmailer/index.php on line 14 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: Name in /var/www/pmailer/index.php on line 18 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: From in /var/www/pmailer/index.php on line 22 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: Email in /var/www/pmailer/index.php on line 26 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: CC in /var/www/pmailer/index.php on line 31 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: BCC in /var/www/pmailer/index.php on line 35 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: Subject in /var/pmailer/index.php on line 40 [04-Aug-2018 00:27:52 UTC] PHP Notice: Undefined variable: Message in /var/www/pmailer/index.php on line 44 [04-Aug-2018 00:27:54 UTC] Call to undefined method PHPMailer\PHPMailer\PHPMailer::setFromName() This is mailer.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'); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'vendor/phpmailer/phpmailer/src/Exception.php'; require 'vendor/phpmailer/phpmailer/src/PHPMailer.php'; require 'vendor/phpmailer/phpmailer/src/SMTP.php'; $mail = new PHPMailer(true); $From = $_POST['from']; $Name = $_POST['name']; $Email = $_POST['email']; $Subject = $_POST['subject']; $Message = $_POST['message']; $CC = $_POST['cc']; $BCC = $_POST['bcc']; print_r($_POST); try { //Server settings $mail->SMTPDebug = 2; $mail->isSMTP(); $mail->Host = 'localhost'; $mail->SMTPAuth = false; $mail->Port = 25; //Recipients $mail->AddReplyTo("$Email"); $mail->setFrom($From); $mail->setFromName($Name); $To = "$Email"; $mail->addAddress($To); $mail->addCC($CC); $mail->addBCC($BCC); //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject($Subject); $mail->Body($Message); $mail->AltBody($Message); $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } ?> Any help please?
  14. After search i got this piece of php code to insert multiple rows to mysql database but this print error: Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2031 in /var/www/quran.eu.org/insert/pdotest.php:31 Stack trace: #0 /var/www/quran.eu.org/insert/pdotest.php(31): PDOStatement->execute() #1 {main} thrown in /var/www/quran.eu.org/insert/pdotest.php on line 31 This is pdotest.php to insert values: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $host = 'localhost'; $db = 'test'; $user = 'user'; $pass = ''; $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); /////// $cat_id=isset($_POST['cat-id']); $subcategory=isset($_POST['subcategory']); $subcat2=isset($_POST['subcat2']); $subcategory2=isset($_POST['subcategory2']); $pdo->beginTransaction(); ///... $stmt = $pdo->prepare('INSERT INTO subcategory (cat_id, subcategory, subcat2) VALUES (:cat_id, :subcategory, :subcat2), (:cat_id, :subcategory2, :subcat2)'); $stmt->bindValue(':cat_id', $cat_id); $stmt->bindValue(':subcategory', $subcategory); $stmt->bindValue(':subcat2', $subcat2); $stmt->bindValue(':cat_id', $cat_id); $stmt->bindValue(':subcategory', $subcategory2); $stmt->bindValue(':subcat2', $subcat2); ///... $stmt->execute(); ?>
  15. I search the internet to find the solution from multiple row insertion there was many codes but i cannot use for my query this is a piece of code, please help how to execute for multiple rows insertion: <?php $host = 'localhost'; $db = 'test'; $user = 'user'; $pass = ''; $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); /////// $cat_id=$_POST['cat-id']; $subcategory=$_POST['subcategory']; $subcat2=$_POST['subcat2']; $subcategory2=$_POST['subcategory2']; $sql = "INSERT INTO subcategory (cat_id, subcategory, subcat2) VALUES (?,?,?),(?,?,?)"; $stmt= $pdo->prepare($sql); $stmt->execute([$cat_id, $subcategory, $subcat2],[$cat_id, $subcategory2, $subcat2]); ?>
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.