php-CRUD

<Beginner PHP><Array><Loop><Function><Pre-Def variable><Session><Read Write File><CRUD>

 

Include & Require

Allow for insertion of the content of one PHP file into another PHP file, before the server  executes it.
Include doesn`t produce error if it can not find the file.

Include

We have a header file
header.php
<?php
echo `Welcome`
?>

To include the header file in a page / in multiple pages
<html>
<body>
<?php
include `header.php`;
?>
</body>
</html>

Require

Require is same as include, but if it can not find the file it cease execution and produce error.


PHP Forms $_GET & $_POST

Their purpose is to collect data that has been entered into a form

somefile.php
<form action="first.php" method="post">
<p>Name: <input type="text" name="name" /></p>
<p><input type="submit" name="submit" value="submit" /></p>
</form>

About the form

Action: it is an attribute
Submitted form is sent to php file named first.php
Name: names are used to access data with PHP

Accessing the posted form


first.php 
<?php echo $_POST["name"];?>

the $_POST superglobal array holds:
keys: names of the form: name, age, sexe
values: input data entered by user

Two method for submitting forms:

GET: visible to all, limit on data amount, possible to bookmark page
POST: invisible to others, no limits on data, has advantage functionality, post is prefered for submitting data


 <?php
?>
 <?php
?>


Comments

Popular posts from this blog

Programming- AI, machine learning

Programming -- JS, C, C++, Python

links - Robotic