Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Precious Metals | Quotes</title>
- <link href="styles.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <?php
- //Set the readCSV as a function so you avoid the need to type it out.
- function readCSV($csvFile) {
- $handle = fopen($csvFile, 'r');
- while (!feof($handle) ) {
- $file[] = fgetcsv($handle, 1024);
- }
- return $file;
- }
- //Open the CSV files (Rates and metals)
- $file1 = 'Rates.csv';
- $file2 = 'metals.csv';
- $file_rate = readCSV($file1);
- $file_metal = readCSV($file2);
- //handle any errors first
- ini_set('display_errors',0);
- $amount = $_REQUEST['amountvalue'];
- $option = $_REQUEST['sweetvalue'];
- ?>
- <div id='main'>
- <div id='titleImage'><img src='logo.png' width='750' height='200' alt='Precious Metals Title' /></div>
- <div id='menu-wrapper'>
- <div id='menu'>
- <ul>
- <li><a href='index.php'>Home</a></li>
- <li class='current_page_item'><a href='#'>Quotes</a></li>
- <li><a href='register.php'>Register</a></li>
- </ul>
- </div>
- </div>
- <div class='forms'>
- <h1>Get a Quote</h1>
- <?php
- $space = " ";
- //Assign a variable to the values entered by the user in the form below
- $option = $_POST['metal'];
- $weight = $_POST['amountvalue'];
- //Use an If statement to check if any data has been entered.
- if($_REQUEST['amountvalue']==NULL){
- $errormessage .= " $space $space $space Please enter a weight for $option";
- }
- else if($_REQUEST['amountvalue']<=0){
- echo" $space $space $space Please enter a value above 0g";
- }
- else if( isset( $_REQUEST['calculate'])){
- $operator=$_REQUEST['metal'];
- if($operator==$file_metal[0][0])
- {
- $add = $_REQUEST['amountvalue'];
- $res = $add * $file_metal[0][1];
- $res2 = $file_metal[0][1]* $add * $file_rate[0][1];
- $res3 = $file_metal[0][1]* $add * $file_rate[1][1];
- }
- if($operator==$file_metal[1][0])
- {
- $add = $_REQUEST['amountvalue'];
- $res = $add * $file_metal[1][1];
- $res2 = $file_metal[1][1]* $add * $file_rate[0][1];
- $res3 = $file_metal[1][1]* $add * $file_rate[1][1];
- }
- if($operator==$file_metal[2][0])
- {
- $add = $_REQUEST['amountvalue'];
- $res = $add * $file_metal[2][1];
- $res2 = $file_metal[2][1]* $add * $file_rate[0][1];
- $res3 = $file_metal[2][1]* $add * $file_rate[1][1];
- }
- if($operator==$file_metal[3][0])
- {
- $add = $_REQUEST['amountvalue'];
- $res = $add * $file_metal[3][1];
- $res2 = $file_metal[3][1]* $add * $file_rate[0][1];
- $res3 = $file_metal[3][1]* $add * $file_rate[1][1];
- }
- $errorMessage = "Thank you, below is your quote for " . "$amount" . " grams of " . "$option" . "";
- }
- ?>
- <form action='quotes.php' method='post' name='quote'>
- <table style="border:groove #000000" width="750px">
- <tr>
- <td>Type of metal: </td>
- <td>
- <select name="metal" style="width: 120px">
- <option><?php echo $file_metal[0][0]?></option>
- <option><?php echo $file_metal[1][0]?></option>
- <option><?php echo $file_metal[2][0]?></option>
- <option><?php echo $file_metal[3][0]?></option>
- </select></form></td>
- </tr>
- <tr>
- <td>Metal Amount</td>
- <td class="auto-style5">
- <input name="amountvalue" type="number" style="color:red"/>
- g</td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="calculate" value="Calculate" /></td>
- </tr>
- <tr>
- <td colspan="2"><?php
- if(!empty($errorMessage)){
- echo("<ul>" . $errorMessage . "</ul>\n");
- }
- else
- ?></td>
- </tr>
- <!--- Rounding the final values to 2 decimal places so it is easier on the eye -->
- <tr>
- <td>Amount in GBP: </td>
- <td>£<?php echo round($res ,2) ?> </td>
- </tr>
- <tr>
- <td>Amount in USD: </td>
- <td>$<?php echo round($res2 ,2) ?> </td>
- </tr>
- <tr>
- <td>Amount in EUR: </td>
- <td>€<?php echo round($res3 ,2) ?> </td>
- </tr>
- </table>
- </div>
- <p><?php echo"$space";?>If you have more than 500g of scrap metal to sell please telephone us for a quote</p>
- </div>
- </body>
- </html>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Precious Metals | Register</title>
- <link href="styles.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <div id='main'>
- <div id='titleImage'><img src='logo.png' width='750' height='200' alt='Precious Metals Title' /></div>
- <div id='menu-wrapper'>
- <div id='menu'>
- <ul>
- <li><a href='index.php'>Home</a></li>
- <li><a href='quotes.php'>Quotes</a></li>
- <li class='current_page_item'><a href='#'>Register</a></li>
- </ul>
- </div>
- </div>
- <div class='forms'>
- <h1>Register</h1>
- <form action='register.php' method='post' name='register'>
- <table>
- <tr>
- <td>Username:</td><td><input type="text" name="user" /></td>
- </tr>
- <tr>
- <td>Email:</td><td><input type="text" name="pass" /></td>
- </tr>
- <tr>
- <td>Password:</td><td><input type="text" name="email" /></td>
- </tr>
- <tr>
- <td>Company:</td><td><input type="text" name="company" /></td>
- </tr>
- <tr>
- <td><input type="submit" value="Submit"></td>
- </tr>
- </table>
- </form>
- </div>
- </div>
- <?php
- $username = "oavcs67";
- $password = "";
- $hostname = "";
- $dbhandle = mysql_connect($hostname, $username, $password) or die("Could not connect to database");
- $selected = mysql_select_db("1", $dbhandle);
- if(isset($_POST['user']) && isset($_POST['pass']) && isset($_POST['email']) && isset($_POST['company'])){
- $user = $_POST['user'];
- $pass = $_POST['pass'];
- $email = $_POST['email'];
- $company = $_POST['company'];
- $query = mysql_query("SELECT * FROM info WHERE Username='$user' && Password='$pass'");
- if(mysql_num_rows($query) > 0) {
- echo "Username has already been taken, sorry about that";
- }
- else{
- mysql_query("INSERT INTO info (name, email, password, company, active) VALUES ('$user', '$pass', '$email', '$company', '0')");
- header("location:index.php");
- }
- }
- mysql_close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement