Mysql Script
Upcoming SlideShare
Loading in...5
×
 

Mysql Script

on

  • 1,620 views

 

Statistics

Views

Total Views
1,620
Views on SlideShare
1,620
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Mysql Script Mysql Script Presentation Transcript

    • 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.
      ?>