SlideShare a Scribd company logo
PHP-MYSQL Script
PHP FORM <?php require_once ('mysql/mysql_connect.php');  if (isset($_POST['submit'])) { // Handle the form.  { // Add name to the database. $query = "INSERT INTO your_table (first_name) VALUES ('$first_name')"; if ($result = @mysql_query ($query)) { // Worked. echo '<p>The name has been saved.</p>'; } else { // If the query did not run OK. echo '<p><font color="red">Your submission could not be processed due to a system error.</font></p>';  } } else { // Failed a test. echo '<p><font color="red">Please click "back" and try again.</font></p>'; } } else { // Display the form. ?>
PHP FORM CONTINUATION <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="content">   <h2>  Add Name</h2> </div> <table>    <tr>     <td>First Name:</td>     <td><input type="text" name="first_name" size="30" maxlength="30" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></td>     </tr> </table> <div align="center"><input type="submit" name="submit" value="Submit" /></div>   </form><!-- End of Form --> <?php } // End of main conditional. ?>
Mysql Connect <?php // This file contains the database access information for the database. This file also establishes a connection to MySQL and selects the database.   define ('DB_USER', 'root'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost'); define ('DB_NAME', '');   // Make the connnection and then select the database. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );   // Function for escaping and trimming form data. function escape_data ($data) {  	global $dbc; 	if (ini_get('magic_quotes_gpc')) { 		$data = stripslashes($data); 	} 	return mysql_real_escape_string (trim ($data), $dbc); } // End of escape_data() function. ?>

More Related Content

Viewers also liked

R2 b12 función raíz cuadrada
R2 b12  función raíz cuadradaR2 b12  función raíz cuadrada
R2 b12 función raíz cuadradaYussel Ruiz
 
R2 b14 función racional
R2 b14 función racionalR2 b14 función racional
R2 b14 función racionalYussel Ruiz
 
R3 b16 trigonométricas
R3 b16 trigonométricasR3 b16 trigonométricas
R3 b16 trigonométricasYussel Ruiz
 
Padarias normas
Padarias normasPadarias normas
Padarias normas
Luis Araujo
 
R3 b15 valor absoluto
R3 b15 valor absolutoR3 b15 valor absoluto
R3 b15 valor absolutoYussel Ruiz
 
Estrategias competitivas básicas
Estrategias competitivas básicasEstrategias competitivas básicas
Estrategias competitivas básicas
LarryJimenez
 

Viewers also liked (7)

R2 b12 función raíz cuadrada
R2 b12  función raíz cuadradaR2 b12  función raíz cuadrada
R2 b12 función raíz cuadrada
 
R2 b14 función racional
R2 b14 función racionalR2 b14 función racional
R2 b14 función racional
 
R3 b16 trigonométricas
R3 b16 trigonométricasR3 b16 trigonométricas
R3 b16 trigonométricas
 
Padarias normas
Padarias normasPadarias normas
Padarias normas
 
R1 b6
R1 b6R1 b6
R1 b6
 
R3 b15 valor absoluto
R3 b15 valor absolutoR3 b15 valor absoluto
R3 b15 valor absoluto
 
Estrategias competitivas básicas
Estrategias competitivas básicasEstrategias competitivas básicas
Estrategias competitivas básicas
 

Similar to Mysql Script

Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Securitymussawir20
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In PhpHarit Kothari
 
High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testingpetersergeant
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstart
guestfd47e4c7
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operatorsmussawir20
 
Maintaining your own branch of Drupal core
Maintaining your own branch of Drupal coreMaintaining your own branch of Drupal core
Maintaining your own branch of Drupal core
drumm
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
Alin Taranu
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
Intro to #memtech PHP 2011-12-05
Intro to #memtech PHP   2011-12-05Intro to #memtech PHP   2011-12-05
Intro to #memtech PHP 2011-12-05Jeremy Kendall
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
Ankush Jain
 
Php Sessoins N Cookies
Php Sessoins N CookiesPhp Sessoins N Cookies
Php Sessoins N Cookiesmussawir20
 
PHP Security
PHP SecurityPHP Security
PHP Security
manugoel2003
 

Similar to Mysql Script (20)

Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Security
 
Php 3 1
Php 3 1Php 3 1
Php 3 1
 
Php My Sql
Php My SqlPhp My Sql
Php My Sql
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testing
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
Ubi comp27nov04
Ubi comp27nov04Ubi comp27nov04
Ubi comp27nov04
 
Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstart
 
Further Php
Further PhpFurther Php
Further Php
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operators
 
Maintaining your own branch of Drupal core
Maintaining your own branch of Drupal coreMaintaining your own branch of Drupal core
Maintaining your own branch of Drupal core
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
Intro to #memtech PHP 2011-12-05
Intro to #memtech PHP   2011-12-05Intro to #memtech PHP   2011-12-05
Intro to #memtech PHP 2011-12-05
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Php Sessoins N Cookies
Php Sessoins N CookiesPhp Sessoins N Cookies
Php Sessoins N Cookies
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Php security3895
Php security3895Php security3895
Php security3895
 

More from lotlot

Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchartlotlot
 
Form Script
Form ScriptForm Script
Form Scriptlotlot
 
Mysql Aggregate
Mysql AggregateMysql Aggregate
Mysql Aggregatelotlot
 
Php Form
Php FormPhp Form
Php Formlotlot
 
Php Loop
Php LoopPhp Loop
Php Looplotlot
 
Php Condition Flow
Php Condition FlowPhp Condition Flow
Php Condition Flowlotlot
 
Php-Continuation
Php-ContinuationPhp-Continuation
Php-Continuationlotlot
 
Hariyali - India
Hariyali - IndiaHariyali - India
Hariyali - Indialotlot
 
The Province Of Davao Oriental
The Province Of Davao OrientalThe Province Of Davao Oriental
The Province Of Davao Orientallotlot
 
Annual Review
Annual ReviewAnnual Review
Annual Reviewlotlot
 

More from lotlot (11)

Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
 
Form Script
Form ScriptForm Script
Form Script
 
Mysql Aggregate
Mysql AggregateMysql Aggregate
Mysql Aggregate
 
Mysql
MysqlMysql
Mysql
 
Php Form
Php FormPhp Form
Php Form
 
Php Loop
Php LoopPhp Loop
Php Loop
 
Php Condition Flow
Php Condition FlowPhp Condition Flow
Php Condition Flow
 
Php-Continuation
Php-ContinuationPhp-Continuation
Php-Continuation
 
Hariyali - India
Hariyali - IndiaHariyali - India
Hariyali - India
 
The Province Of Davao Oriental
The Province Of Davao OrientalThe Province Of Davao Oriental
The Province Of Davao Oriental
 
Annual Review
Annual ReviewAnnual Review
Annual Review
 

Recently uploaded

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Mysql Script

  • 2. PHP FORM <?php require_once ('mysql/mysql_connect.php'); if (isset($_POST['submit'])) { // Handle the form. { // Add name to the database. $query = "INSERT INTO your_table (first_name) VALUES ('$first_name')"; if ($result = @mysql_query ($query)) { // Worked. echo '<p>The name has been saved.</p>'; } else { // If the query did not run OK. echo '<p><font color="red">Your submission could not be processed due to a system error.</font></p>'; } } else { // Failed a test. echo '<p><font color="red">Please click "back" and try again.</font></p>'; } } else { // Display the form. ?>
  • 3. PHP FORM CONTINUATION <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="content"> <h2> Add Name</h2> </div> <table> <tr> <td>First Name:</td> <td><input type="text" name="first_name" size="30" maxlength="30" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></td> </tr> </table> <div align="center"><input type="submit" name="submit" value="Submit" /></div>   </form><!-- End of Form --> <?php } // End of main conditional. ?>
  • 4. Mysql Connect <?php // This file contains the database access information for the database. This file also establishes a connection to MySQL and selects the database.   define ('DB_USER', 'root'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost'); define ('DB_NAME', '');   // Make the connnection and then select the database. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );   // Function for escaping and trimming form data. function escape_data ($data) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysql_real_escape_string (trim ($data), $dbc); } // End of escape_data() function. ?>