Sunday, 27 March 2022

Send email using php mail function

 <?php

$to="recievermail@yourdomail.com";

               // Your subject

                 $subject= "Your email subjest html email";

               

                // From

                        $headers = "From: Adquash Dot Com <noreply@youradmin.com>\r\n";

                        $headers .= "Reply-To: support@youradmin.com\r\n";

                        $headers .= "Return-Path: Adquash Dot Com <noreply@youradmin.com>\r\n";

                        //$headers .= "CC: info@youradmin.com\r\n";

                        $headers .= "MIME-Version: 1.0\r\n";

                        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

//                $header .= "Content-type:text/html;charset=UTF-8" . "\r\n";

                $img = 'https://adquash.com/images1/09072020054921cloud.png'; // replace image path

                

                // Your message

                $message="

                

                <img src='$img'>

                emailads by Website: www.adquash.com<br><br>

                Useful information<br>

                This email ads a sponsor paid email ads So<br>

Avoid scams by acting locally or paying with PayPal , Western Union, Moneygram or other anonymous payment services<br>

Don't buy or sell outside of your country. Don't accept cashier cheques from outside your country<br>

Adquash.com never involved in any transaction, and does not handle payments, shipping, guarantee transactions, provide escrow services, or offer buyer protection or seller certification";

                //echo "b" . $emailcontent;   

                // send email

              $sentmail = mail($to,$subject,$message,$headers);

if($sentmail > "0"){ echo " sent";}


Tuesday, 1 February 2022

 paypal form

<form action='https://www.paypal.com/donate' method='post' target='_top'>

<!-- Paypal business test account email id so that you can collect the payments. -->

<input type='hidden' name='business' value='YOUR_PAYPAL_EMAIL_ID'>

<!-- Buy Now button. -- _xclick>

<input type='hidden' name='cmd' value='_donations'>

<!-- Details about the item that buyers will purchase. -->

<input type='hidden' name='item_name' value='$sql[donate_for]'>

<input type='hidden' name='item_number' value='$sql[order_id]'>

<input type='hidden' name='amount' value='$sql[amount]'>

<input type='hidden' name='currency_code' value='USD' readonly>

<!-- URLs -->

<input type='hidden' name='cancel_return' value='https://localhost/donate-us.php'>

<input type='hidden' name='return' value='https://localhost/success.php'>

<!-- payment button. -->

<!--input type='image' name='submit' border='0'

src='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif' alt='Donate'>

<img alt='' border='0' width='1' height='1' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' -->

<button class='theme-btn btn-style-one' type='submit' name='submit'><span>Donate with Paypal</span></button>

</form>




Success.php


<h1>Your payment has been successful.</h1>

<?php

error_reporting(1);

include_once("connect.php");

//Store transaction information into database from PayPal

$item_number = $_GET['item_number']; 

$txn_id = $_GET['tx'];

$payment_gross = $_GET['amt'];

$currency_code = $_GET['cc'];

$payment_status = $_GET['st'];

//Get product price to store into database

$sql = "SELECT * FROM donate_us WHERE order_id = ".$item_number;

$resultset = mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));

$row = mysqli_fetch_assoc($resultset);

if(!empty($txn_id) && $payment_gross == $row['price']){

    //Insert tansaction data into the database

   // mysqli_query($conn, "INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");

    mysqli_query($conn, "UPDATE donate_us SET pay_id = '$txn_id',payment_status = 'Done' WHERE WHERE order_id = '$item_number'");

$last_insert_id = mysqli_insert_id($conn);  

?>

<h1>Your payment has been successful.</h1>

    <h1>Your Payment ID - <?php echo $last_insert_id; ?>.</h1>

    <h1>Your Payment txn ID - <?php echo $txn_id; ?>.</h1>

<?php

}else{

?>

<h1>Your payment has failed.</h1>

<?php

}

?>

Export sql data in excel using php

 <?php

$conn = mysqli_connect("localhost", "user_name", "password", "database_name");

$id = $_GET["id"];

$sqlQuery = "SELECT * FROM table_name'";

$resultSet = mysqli_query($conn, $sqlQuery) or die("database error:". mysqli_error($conn));

$developersData = array();

while( $developer = mysqli_fetch_assoc($resultSet) ) {

$developersData[] = $developer;

}

//if($id > "0") {

$fileName = "webdamn_export_".date('Ymd') . ".xls";

header("Content-Type: application/vnd.ms-excel");

header("Content-Disposition: attachment; filename=\"$fileName\"");

$showColoumn = false;

if(!empty($developersData)) {

  foreach($developersData as $developerInfo) {

if(!$showColoumn) {  

  echo implode("\t", array_keys($developerInfo)) . "\n";

  $showColoumn = true;

}

echo implode("\t", array_values($developerInfo)) . "\n";

  }

}

exit;  

//}

?>

Sunday, 23 January 2022

Only Alphabets and Numbers allowed in text field

<input type="text" id="txtName"/>
<span id="lblError" style="color: red"></span>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#txtName").keypress(function (e) {
            var keyCode = e.keyCode || e.which;
 
            $("#lblError").html("");
 
            //Regex for Valid Characters i.e. Alphabets and Numbers.
            var regex = /^[A-Za-z0-9 ]+$/;
 
            //Validate TextBox value against the Regex.
            var isValid = regex.test(String.fromCharCode(keyCode));
            if (!isValid) {
                $("#lblError").html("Only Alphabets and Numbers allowed.");
            }
 
            return isValid;
        });
    });
</script>