<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elijah Emmanuel</title>
    <description>The latest articles on DEV Community by Elijah Emmanuel (@vinhpedro).</description>
    <link>https://dev.to/vinhpedro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F509650%2Ff3c93f60-53bb-47c8-a00a-ca2f7effd7f1.jpeg</url>
      <title>DEV Community: Elijah Emmanuel</title>
      <link>https://dev.to/vinhpedro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vinhpedro"/>
    <language>en</language>
    <item>
      <title>How can I avoid multiple deduction from stocks in my SQL db in php while loop?</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Fri, 12 Aug 2022 20:28:00 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-avoid-multiple-deduction-from-stocks-in-my-sql-db-in-php-while-loop-1nk4</link>
      <guid>https://dev.to/vinhpedro/how-can-i-avoid-multiple-deduction-from-stocks-in-my-sql-db-in-php-while-loop-1nk4</guid>
      <description>&lt;p&gt;Please 🙏 guys, I have been having issues when I have alot of people trying to checkout after placing orders on my site. &lt;br&gt;
I made use of while loop to ensure that the quantity ordered deducts from available quantity in my SQL database, but instead of deducting as planned, it deducts excess.&lt;br&gt;
Here is my code below....&lt;br&gt;
Am I doing it the wrong way?&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;?php
//Database connection
include("db/config.php");

//Session to get user id
$user_id=$_SESSION['id'];
$statuss='added';

   $value2='';

    //Query to fetch last inserted invoice number and create a new invoice number 
    $query = "SELECT invoice_no from invoice order by invoice_no DESC LIMIT 1";
    $stmt = $conn-&amp;gt;query($query);
    if(mysqli_num_rows($stmt) &amp;gt; 0) {
        if ($row = mysqli_fetch_assoc($stmt)) {
            $value2 = $row['invoice_no'];
            $value2 = substr($value2, 10, 13);//separating numeric part
            $value2 = $value2 + 1;//Incrementing numeric part
            $value2 = "ARW/19-20/" . sprintf('%03s', $value2);//concatenating incremented value
            $value = $value2; 
        }
    } 
    else {
        $value2 = "ARW/19-20/001";
        $value = $value2;
    }
    // echo $value;
if(isset($_POST['check_out'])){

   //Main code

//Get all input values
$name=mysqli_real_escape_string($conn,$_POST['name']);
    $phone=mysqli_real_escape_string($conn,$_POST['phone']);
    $address=mysqli_real_escape_string($conn,$_POST['address']);
    $payment_method=mysqli_real_escape_string($conn,$_POST['payment_mtd']);




        $added='added';
//Get session name     $user_name=$_SESSION['name'];

//Query to update order operation table
        $sql="UPDATE order_operation SET name='$name', user_name='$user_name', phone='$phone', address='$address',payment='$payment_method' WHERE user_id=$user_id AND status='$added'";   
        if($conn-&amp;gt;query($sql) === TRUE){
//Declare variables       
$before='added';
$status='completed';

//Update order operation with created invoice number

$sql="UPDATE order_operation SET status=?, invoice_no=? WHERE user_id='$user_id' AND status='$before'";
            $stmt=$conn-&amp;gt;prepare($sql); 
            $stmt-&amp;gt;bind_param('ss',$status,$value);
            if($stmt-&amp;gt;execute()){
                $sql="INSERT INTO invoice(invoice_no,user_id) VALUES('$value','$user_id')";
                $conn-&amp;gt;query($sql);
                    //Deduct from stock
                    $sql = "SELECT * FROM `order_operation` WHERE invoice_no='$value'";
                    $sql_run = mysqli_query($conn, $sql);

                    while ($row = mysqli_fetch_array($sql_run)) {
 //Deduct from stock since the order id's meet the requirements                                         $deduct=$row['stock_quantity'] - $row['quantity'];
                            $stock_id=$row['stock_id'];
                           $connector= "UPDATE stocks SET quantity =  '$deduct' WHERE id = $stock_id" ;
                           if($conn-&amp;gt;query($connector) === TRUE){


                                $_SESSION['customer_name']=$name;   
                                $_SESSION['phone']=$phone;
                                $_SESSION['address']=$address;
                                $_SESSION['payment']=$payment_method;
                                $_SESSION['invoice_no']=$row['invoice_no'];
                                header('location:order_invoice.php');

                           }else{
                            echo $conn-&amp;gt;error;
                           }



                        }
                        //End of deduct from stock

                    $conn-&amp;gt;close();

                 }else{
                    die($conn-&amp;gt;error);

                 }
             }else{

                 die($conn-&amp;gt;error);

             }


               $stmt-&amp;gt;close();
               $conn-&amp;gt;close();

}


?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>php</category>
      <category>sql</category>
    </item>
    <item>
      <title>Please How  can  I convert  the  following   object  oriented  PDO fetch_assoc to MYsqli Format below. </title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Thu, 02 Dec 2021 14:00:46 +0000</pubDate>
      <link>https://dev.to/vinhpedro/please-how-can-i-convert-the-following-object-oriented-pdo-fetchassoc-to-mysqli-format-below-5220</link>
      <guid>https://dev.to/vinhpedro/please-how-can-i-convert-the-following-object-oriented-pdo-fetchassoc-to-mysqli-format-below-5220</guid>
      <description>&lt;p&gt;Hi Great Developers, I am having a difficult time fetching data from my database using object PHP as below. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So I have two pages,&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;One for fetching data from my DB and returning it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And another for displaying the data from my database fetched from the first page. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;As Below&lt;/strong&gt;&lt;br&gt;
The code below is a function written with PDO&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First page.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function get_messages() 
{
//fetch data from db

$sql="SELECT user_name, msg, timestamp FROM message_chat";

//prepare and execute. 
$stmt=$conn-&amp;gt;prepare($sql);

$stmt-&amp;gt;execute() ;

//Now this is the line thats making things complicated. 

return $stmt-&amp;gt;fetchAll(PDO::FETCH_ASSOC) ;
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the second page is meant to return the generated data's from the above code, but its not happening. &lt;br&gt;
Please how can I convert the above PDO &lt;strong&gt;fetch_assoc&lt;/strong&gt; statement to mysqli so I can use it in my project. &lt;/p&gt;

</description>
      <category>sql</category>
      <category>php</category>
    </item>
    <item>
      <title>HOW TO RETURN PDO fetch_assoc FROM PDO TO MYsqli</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Thu, 25 Nov 2021 01:30:50 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-to-return-pdo-fetchassoc-from-pdo-to-mysqli-32bi</link>
      <guid>https://dev.to/vinhpedro/how-to-return-pdo-fetchassoc-from-pdo-to-mysqli-32bi</guid>
      <description>&lt;p&gt;please how can I convert the following the following code from PDO to MYsqli in order to return it. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aQYgaEd1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phhf2zeqklsqvti2kc71.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aQYgaEd1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phhf2zeqklsqvti2kc71.jpg" alt="Image description" width="794" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>sql</category>
    </item>
    <item>
      <title>HOW CAN I LIMIT THE MAXIMUM FILE UPLOAD LIMIT PER USER  IN PHP.</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Tue, 02 Nov 2021 03:09:35 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-limit-the-maximum-file-upload-limit-per-user-in-php-1887</link>
      <guid>https://dev.to/vinhpedro/how-can-i-limit-the-maximum-file-upload-limit-per-user-in-php-1887</guid>
      <description>&lt;p&gt;Hello guys,&lt;br&gt;
i have been trying for some days now to make it possible for each user in my website to only &lt;strong&gt;upload a maximum of 4 images&lt;/strong&gt; and when ever he/she wants to upload the fifth image an error massage would be echoed telling the user that &lt;strong&gt;The maximum image to be uploaded have reached and cannot exceed 4 image&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Below is the sample of the code on form submit
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (isset($_POST['upload'])) { 
// if upload button on the form is clicked

// name of the uploaded file
$filename = $_FILES['photo']['name'];

//location
$destination = '../images/business.cover/' . $filename;

// get the file extension
$extension = pathinfo($filename, PATHINFO_EXTENSION);

// the physical file on a temporary uploads directory on the server
$file = $_FILES['photo']['tmp_name'];
$size = $_FILES['photo']['size'];

// get id
$id=$_GET['id'];

//check is form is empty
if(empty($_POST['photo'])){
    $cover_msg= "&amp;lt;div class='alert alert-danger'&amp;gt;Empty cover phto field&amp;lt;/div&amp;gt;";
}

//check file extension and maximum file size
if (!in_array($extension, ['jpg', 'gif', 'jpeg','png'])) {
    $cover_msg= "&amp;lt;div class='alert alert-danger'&amp;gt;You file extension must be .jpg .jpeg .gif .png&amp;lt;/div&amp;gt;";
} elseif ($_FILES['photo']['size'] &amp;gt; 50000000) { // file shouldn't be larger than 1Megabyte
    $cover_msg= "&amp;lt;div class='alert alert-danger'&amp;gt;File too large!&amp;lt;/div&amp;gt;";

} else {


// move the uploaded (temporary) file to the specified destination
    if (move_uploaded_file($file, $destination);) {

$sql = "INSERT INTO business(image) VALUES('$filename') WHERE id=$id";  

$cover_msg="&amp;lt;div class='alert alert-success'&amp;gt;Information uploaded Successfully&amp;lt;/div&amp;gt;";
if (mysqli_query($conn, $sql)) {
} else {
die( "Failed to upload file".$conn-&amp;gt;error);
}

}

}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;PLEASE HELP, ANYONE&lt;/strong&gt;
&lt;/h2&gt;

</description>
      <category>php</category>
      <category>sql</category>
    </item>
    <item>
      <title>How can i create a chat app with json on php</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Thu, 07 Oct 2021 15:35:56 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-create-a-chat-app-with-json-on-php-1opc</link>
      <guid>https://dev.to/vinhpedro/how-can-i-create-a-chat-app-with-json-on-php-1opc</guid>
      <description>&lt;p&gt;Please how can I create a chatting app with php, I have tried all means but but don't know what am missing, &lt;br&gt;
Below is the cade for the database connection and json code used to convert it&lt;/p&gt;

&lt;p&gt;&amp;lt;?php &lt;br&gt;
$localhost="localhost";&lt;br&gt;
$user="root";&lt;br&gt;
$password="";&lt;br&gt;
$db='chat';&lt;br&gt;
$conn=new mysqli($localhost,$user,$password,$db);&lt;/p&gt;

&lt;p&gt;if ($conn-&amp;gt;connect_error) {&lt;br&gt;
    die("unable to connect to server");&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$result=array();&lt;br&gt;&lt;br&gt;
$message= isset($_POST['message']) ? $_POST['message']:null;&lt;br&gt;
$from=isset($_POST['from']) ? $_POST['from']:null;&lt;/p&gt;

&lt;p&gt;if(!empty($message) &amp;amp;&amp;amp; !empty($from)){&lt;br&gt;
    $sql="INSERT INTO &lt;code&gt;chat&lt;/code&gt;(&lt;code&gt;message&lt;/code&gt;,&lt;code&gt;from&lt;/code&gt;) VALUES('".$message."','".$from."')";&lt;br&gt;
    $result['send_status']=$conn-&amp;gt;query($sql);&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
//print massages&lt;br&gt;
$start =isset($_GET['start']) ? intval($_GET['start']):0;&lt;br&gt;
$items = $conn-&amp;gt;query("SELECT * FROM &lt;code&gt;chat&lt;/code&gt; WHERE &lt;code&gt;id&lt;/code&gt; &amp;gt; ".$start);&lt;br&gt;
while ($row=$items-&amp;gt;fetch_assoc()) {&lt;br&gt;
    $result["items"][]=$row;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$conn-&amp;gt;close();&lt;/p&gt;

&lt;p&gt;header('Access-Control-Allow-Origin: * ');&lt;br&gt;
header('Control-Type: application/json');&lt;/p&gt;

&lt;p&gt;echo json_encode($result); &lt;br&gt;
? &amp;gt;&lt;/p&gt;

&lt;p&gt;And below is the code in my index page:&lt;/p&gt;

&lt;p&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
&lt;/p&gt;


&lt;br&gt;
    &amp;lt;!--  --&amp;gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta charset="UTF-8"&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&amp;lt;title&amp;gt;CHAT&amp;lt;/title&amp;gt;
&amp;lt;script src="jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
    var from = null, start = 0, url = "http://localhost/chat.php";
    $(document).ready(function () {
        from = prompt("enter your name");
        load();

        $('form').submit(function (e) {
            $.post(url, {
                message: $('#message').val(),
                from: from
            });
            $('#message').val('');
            return false;
        })
    });

    function load() {
        $.get(url + '?start=' + start, function(result) {
            if (result.items) {
                result.items.forEach(item =&amp;gt; {
                    start = item.id;
                    $('#messages').append(renderMessage(item));
                    console.log(item.status);
                })
            };
            load();
        });
    }

    function renderMessage(item) {
        console.log(item);
    }


&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



    body {
        margin: 0;
        overflow: hidden;
        background: silver;
    }

    #messages {
        height: 83vh;
        overflow: hidden;
        padding: 10px;
    }

    form {
        display: flex;
    }

    input {
        font-size: 1.2rem;
        padding: 10px;
        margin: 10px 5px;
        appearance: none;
        -webkit-appearance: none;
    }

    #message {
        flex: 2;
    }



&lt;br&gt;
      GET JSON&lt;br&gt;
    
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="messages"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;form&amp;gt;
    &amp;lt;input type="text" id="message" autocomplete="off" autofocus placeholder="Type Message..."&amp;gt;
    &amp;lt;input type="submit" value="Send"&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Thanks in advance. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>php</category>
      <category>json</category>
    </item>
    <item>
      <title>How can i integrate a bitcoin payment method on my php website </title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Sun, 23 May 2021 10:50:16 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-integrate-a-bitcoin-payment-method-on-my-php-website-52l9</link>
      <guid>https://dev.to/vinhpedro/how-can-i-integrate-a-bitcoin-payment-method-on-my-php-website-52l9</guid>
      <description>&lt;p&gt;Please, how can i integrate a bitcoin payment method on my php website just like PayPal payment.&lt;/p&gt;

&lt;p&gt;Am currently working on a payment system using php and sql and really need to know about how to integrate this bitcoin payment method.&lt;/p&gt;

</description>
      <category>php</category>
      <category>sql</category>
    </item>
    <item>
      <title>How can i create a CRON operation to add numbers based on timed events in my database.</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Sat, 27 Mar 2021 15:28:50 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-create-a-cron-operation-to-add-numbers-based-on-timed-events-in-my-database-53ko</link>
      <guid>https://dev.to/vinhpedro/how-can-i-create-a-cron-operation-to-add-numbers-based-on-timed-events-in-my-database-53ko</guid>
      <description>&lt;p&gt;please, how can i create a cron operation that will add numbers to the existing numbers based on my present database value when the next event is to be executed?&lt;/p&gt;

&lt;p&gt;here is the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$sql="CREATE EVENT test_event_05
ON SCHEDULE EVERY 1 MINUTE
STARTS CURRENT_TIMESTAMP
ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
   INSERT INTO messages(email,income,created_at)
#i would like to add 20 at the next execution so that the income which is 30 would change to 60;

   VALUES('elijahemmanuel05',30,NOW());";

  if($conn-&amp;gt;query($sql) == "true"){
    echo 'created';
  }else {
    die("not created".$conn-&amp;gt;error);
  }
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;please help me guys, its urgent&lt;/p&gt;

</description>
      <category>php</category>
      <category>sql</category>
    </item>
    <item>
      <title>the reg</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Fri, 19 Mar 2021 18:31:46 +0000</pubDate>
      <link>https://dev.to/vinhpedro/the-reg-47bi</link>
      <guid>https://dev.to/vinhpedro/the-reg-47bi</guid>
      <description>&lt;p&gt;FORM&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
include_once('header.php');
include('../validate/register.php');
?&amp;gt;




&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;link rel="stylesheet" href="./styles/nubastyle.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="../styles/flick/flickity.css"&amp;gt;
    &amp;lt;script src="../styles/flick/flickity.pkgd.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="../styles/jquery/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;link rel="stylesheet" href="../public/styles/style.css"&amp;gt;
    &amp;lt;title&amp;gt;LIBRARY SIGNUP&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;

&amp;lt;/style&amp;gt;

&amp;lt;body&amp;gt;

    &amp;lt;br&amp;gt;
    &amp;lt;div class="container ml-lg-5 mr-lg-5"&amp;gt;


        &amp;lt;div class="row  ml-lg-5 mr-lg-5 p-lg-5"&amp;gt;
            &amp;lt;div class="col  ml-lg-5 mr-lg-5 p-lg-5 shadow"&amp;gt;
                &amp;lt;form action="" method="POST"&amp;gt;

                    &amp;lt;label for="username"&amp;gt;&amp;lt;i class="fa fa-user"&amp;gt;&amp;lt;/i&amp;gt;User Name&amp;lt;/label&amp;gt;
                    &amp;lt;input type="text" name="username" class="form-control"&amp;gt;
                    &amp;lt;div class="text-danger"&amp;gt;&amp;lt;?php echo $username_err?&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;


                    &amp;lt;label for="regno"&amp;gt;Reg No&amp;lt;/label&amp;gt;
                    &amp;lt;input type="text" name="regno" class="form-control"&amp;gt;
                    &amp;lt;div class="text-danger"&amp;gt;&amp;lt;?php echo $regno_err?&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;

                    &amp;lt;label for="email"&amp;gt;&amp;lt;i class="fas fa-envelope"&amp;gt;&amp;lt;/i&amp;gt;Email &amp;lt;/label&amp;gt;
                    &amp;lt;input type="email" name="email" class="form-control" required&amp;gt;

                    &amp;lt;label for="department"&amp;gt; &amp;lt;i class="fa fa-house-user"&amp;gt;&amp;lt;/i&amp;gt; Department&amp;lt;/label&amp;gt;
                    &amp;lt;input type="text" name="department" class="form-control"&amp;gt;

                    &amp;lt;label for="password"&amp;gt;&amp;lt;i class="fa fa-key"&amp;gt;&amp;lt;/i&amp;gt; Password&amp;lt;/label&amp;gt;
                    &amp;lt;input type="password" name="password" class="form-control" required&amp;gt;

                    &amp;lt;input type="submit" value="SUBMIT" class="btn btn-outline-primary"&amp;gt;
                &amp;lt;/form&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;


    &amp;lt;?php include_once('../public/bottom.php')?&amp;gt;

&amp;lt;/body&amp;gt;


&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PHP CODE&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php 
$regno_err=$username_err="";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if (preg_match('/^[a-zA-Z0-9]+$/', $_POST['username']) == 0) {
    $username_err='Username is not valid!';
}
    if(empty(trim($_POST['regno']))){
        $regno_err="please fill in this field";
    }elseif($stmt = $conn-&amp;gt;prepare('SELECT id, username FROM user WHERE regno = ?')) {
        // Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
        $stmt-&amp;gt;bind_param('s', $_POST['regno']);
        $stmt-&amp;gt;execute();
        $stmt-&amp;gt;store_result();
        // Store the result so we can check if the account exists in the database.
        if ($stmt-&amp;gt;num_rows &amp;gt; 0) {
            // Username already exists
            $regno_err= 'regno exists, please choose another!';



        } else {
            $sql="INSERT INTO user(username,regno,email,password,department) VALUES(?,?,?,?,?)";
            if($stmt=$conn-&amp;gt;prepare($sql)){
                $password=password_hash($password,PASSWORD_DEFAULT);
                $username=mysqli_real_escape_string($conn,$_POST['username']);
                $regno=mysqli_real_escape_string($conn,$_POST['regno']);
                $email=mysqli_real_escape_string($conn,$_POST['email']);
                $department=mysqli_real_escape_string($conn,$_POST['department']);

                $stmt-&amp;gt;bind_param('sssss',$username,$regno,$email,$password,$department);
                if($stmt-&amp;gt;execute()){
                    ECHO '&amp;lt;script&amp;gt;alert("SUCCESSFULLY REGISTERED")&amp;lt;/script&amp;gt;';
                }
            }else{
                echo "something went wrong";
            }
        }

    } else {
        // Something is wrong with the sql statement, check to make sure accounts table exists with all 3 fields.
        echo 'Could not prepare statement!';
    }
}$conn-&amp;gt;close();
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How Can i create a Secure SignIn Portal In PHP after Using Password Hash on SignUp Page.</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Fri, 19 Mar 2021 17:46:42 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-create-a-secure-signin-portal-in-php-after-using-password-hash-on-signup-page-27g4</link>
      <guid>https://dev.to/vinhpedro/how-can-i-create-a-secure-signin-portal-in-php-after-using-password-hash-on-signup-page-27g4</guid>
      <description>&lt;p&gt;Please fellow &lt;strong&gt;Devs&lt;/strong&gt;, i just created a Signup(Registration) Portal in PHP using &lt;strong&gt;password&lt;/strong&gt; Hash to store my password in the &lt;strong&gt;Database&lt;/strong&gt;, but i cannot Login to the &lt;strong&gt;welcome page&lt;/strong&gt; because the password passed from the login page is not the same as the Hashed password in the database.&lt;br&gt;
Here is the code below:&lt;br&gt;
someone should please tell me whats wrong, thanks.&lt;/p&gt;

&lt;h6&gt;
  
  
  FORM
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
include_once('../public/header.php');
include('../validate/login.php');
?&amp;gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;link rel="stylesheet" href="../public/styles/style.css"&amp;gt;
    &amp;lt;title&amp;gt;student login&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;


&amp;lt;body&amp;gt;

    &amp;lt;div class="container ml-lg-5 mr-lg-5"&amp;gt;
        &amp;lt;div class="row ml-lg-5 mr-lg-5 p-lg-5"&amp;gt;
            &amp;lt;div class="col ml-lg-5 mr-lg-5 p-lg-5 shadow"&amp;gt;
                &amp;lt;form action="" method="POST"&amp;gt;
                    &amp;lt;div class="text-danger"&amp;gt;&amp;lt;?php echo $err_msg ?&amp;gt;&amp;lt;/div&amp;gt;
                    &amp;lt;label for="regno"&amp;gt;Reg No&amp;lt;/label&amp;gt;
                    &amp;lt;input type="text" name="regno" class="form-control"&amp;gt;
                    &amp;lt;div class="text-danger"&amp;gt;&amp;lt;?php echo $regno_err ?&amp;gt;&amp;lt;/div&amp;gt;

                    &amp;lt;label for="password"&amp;gt;Password&amp;lt;/label&amp;gt;
                    &amp;lt;input type="password" name="password" class="form-control"&amp;gt;
                    &amp;lt;div class="text-danger"&amp;gt;&amp;lt;?php echo $password_err ?&amp;gt;&amp;lt;/div&amp;gt;

                    &amp;lt;input type="submit" value="LOGIN" class="btn btn-outline-primary"&amp;gt;
                &amp;lt;/form&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;


&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  FORM VALIDATION CODE
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$err_msg = $regno_err= $password_err= "";
if($_SERVER["REQUEST_METHOD"] == "POST"){

    if ( !isset($_POST['regno'], $_POST['password']) ) {
        // Could not get the data that should have been sent.
        $err_msg='Please fill both the username and password fields!';
    };

    if(empty(trim($_POST['regno']))){
    $regno_err="please fill in regno";
    }elseif ($stmt = $conn-&amp;gt;prepare('SELECT * FROM user WHERE regno = ?')) {
        // Bind parameters (s = string, i = int, b = blob, etc), in our case the username is a string so we use "s"
        $stmt-&amp;gt;bind_param('s', $_POST['regno']);
        $stmt-&amp;gt;execute();
        // Store the result so we can check if the account exists in the database.
        $stmt-&amp;gt;store_result();

        if($stmt-&amp;gt;num_rows == "false"){
            $regno_err= "user does not exist";
        }else{
            $regno=$_POST['regno'];

            $sql = "SELECT * From user WHERE regno = '{$regno}' ";
            $query = mysqli_query($conn, $sql);

            if(!$query){
                die('unable to query'.$conn-&amp;gt;error);
            }


             while($row = mysqli_fetch_array($query)) {
                    $id            = $row['id'];
                    $username     = $row['username'];
                    $regno_in      =$row['regno'];
                    $email         = $row['email'];
                    $department   = $row['department'];
                    $pass_word     = $row['password'];
                }



            $password=password_verify($pass_word,$_POST['password']);
            if($regno_in ==$regno &amp;amp;&amp;amp; $pass_word == $password){
                echo "you are welcome";
                $_SESSION['password'] = $pass_word;

                echo "your email is:".$_SESSION['password'];
            }else{
                echo "password does not match db";
            }

            }

        $stmt-&amp;gt;close(); 
        }
    }$conn-&amp;gt;close();
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>sql</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How can i deliver the best in PHP to my clients without having full php skills</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Wed, 17 Mar 2021 10:37:33 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-can-i-deliver-the-best-in-php-to-my-clients-without-having-full-php-skills-11bg</link>
      <guid>https://dev.to/vinhpedro/how-can-i-deliver-the-best-in-php-to-my-clients-without-having-full-php-skills-11bg</guid>
      <description>&lt;p&gt;Please fellow developers, How can i deliver the best website in PHP to my clients without having full php skills? &lt;br&gt;
And is it alright to build up the website, launching it online and understanding how to works before going back to learn the code fully just to save time and deliver my work? &lt;br&gt;
Will that also make me a lazy developer? &lt;br&gt;
Please, help me, I need ur advice, please. &lt;/p&gt;

</description>
      <category>php</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to integrage bitcoin payment method in React</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Wed, 27 Jan 2021 03:55:06 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-to-integrage-bitcoin-payment-method-in-react-lfa</link>
      <guid>https://dev.to/vinhpedro/how-to-integrage-bitcoin-payment-method-in-react-lfa</guid>
      <description>&lt;p&gt;Please, how can i integrate a bitcoin payment method on react js web app, just like a PayPal payment. &lt;/p&gt;

&lt;p&gt;Am currently working on a web app with react js and really need to know about how to integrate this bitcoin payment method. &lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
    </item>
    <item>
      <title>How to integrage bitcoin payment method in React. Js</title>
      <dc:creator>Elijah Emmanuel</dc:creator>
      <pubDate>Tue, 26 Jan 2021 20:24:46 +0000</pubDate>
      <link>https://dev.to/vinhpedro/how-to-integrage-bitcoin-payment-method-in-react-js-aaa</link>
      <guid>https://dev.to/vinhpedro/how-to-integrage-bitcoin-payment-method-in-react-js-aaa</guid>
      <description>&lt;p&gt;Please, how can i integrate a bitcoin payment method on react js web app, just like a PayPal payment. &lt;/p&gt;

&lt;p&gt;Am currently working on a web app with react js and really need to know about how to integrate this bitcoin payment method. &lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
    </item>
  </channel>
</rss>
