Posts

Showing posts with the label PHP

How to Send Email using Mailgun PHP API

1. Create an account at Mailgun.com , you would get API Key and a sandbox domain for testing. You shall later add your custom domain too. 2. Create a sample project folder and install Composer. mailguntest is out project name, you can change as per your requirement. >mkdir mailguntest >cd mailguntest >curl -sS https://getcomposer.org/installer | php Once Composer is installed, add Mailgun PHP API / library too. >php composer.phar require mailgun/mailgun-php:~1.7.1 I have used version 1.7.1, you can use any. see https://packagist.org/packages/mailgun/mailgun-php for details. 3. In mailguntest folder, create mailer.php file with below contents: Update the code as per your mailgun code settings: <?php require 'vendor/autoload.php'; use Mailgun\Mailgun; $mg = new Mailgun("write your API key here"); $domain = "write-your-sandbox-domain for testing"; $mg->sendMessage($domain, array( 'from' => 'postmaster@write-your-sa...

PHP Update Form

Image
In PHP Update Form post, I would explain how you can display an HTML form that is already filled or populated. We often need it to update some previous data. Lets first see the code, then we would move to some points that you must understand about creating update form in php: PHP Update Form // Lets assume following are the earlier values that we want to update $name='Asif'; $password = 'mypassword'; $credit_card = 'Visa'; $city = 'Lahore'; $subjects = array("Algorithms", "OOP"); $languages = array("Java", "PHP"); // To populate these values in form, we must set these some attribute of form input controls, see below ?> Update Student Info. Name " /> Password "/> Subjects /> Algorithms />OOP /> Data Structures Credit Card />Visa />Master Card />Amer...

PHP Full Form

Image
In this post I would explain how to process a form using PHP. Before we move to PHP code, lets see how our HTML code looks like which creates the form. I have included all possible basic controls (text, checkbox, radio, option list, etc) to demonstrate how fetching values for different type of controls differ when we write PHP code. Form with all controls Student Registration Form Name Password Subjects Algorithms OOP Data Structures Credit Card Visa Master Card American Express City Lahore Karachi Islamabad Favorite Languages Java PHP Ruby C C# If you know HTML, you know there is nothing special in above file. Its just plain HTML. Notice, action value is full-form-handler.php. It means, when the user submit this form, full-form-handler.php would be executed to ...

PHP Form

Image
In this post I would create a simple form in HTML (with just two input boxes) and then write PHP code to retrieve the form values a user submit using PHP. So in our sample project there are only two files: form.html form-handler.php Let see the form.html code: PHP Form First Name: Last Name: This form will generate following output: There are following points to note: The action attribute value is form-handler.php . It shows, when the form is submitted form-handler.php would process the form. Processing includes, retrieving form data and storing it somewhere if you want to. The input text boxes names are first-name and last-name . On PHP page, we would use these  names to retrieve the values user entered in the PHP form. The Server Side The form-handler.php code retrieves the both input values and display on the next page. Lets first look at the form-handler.php code. $first_name = $_REQUEST['first-name']; $last_name = $_REQUEST['l...