Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "cornwall";
- $con=mysqli_connect('localhost','root','cornwall','ibill');
- // This code creates a connection to the MySQL database in PHPMyAdmin named 'ibill':
- if (mysqli_connect_errno()) {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- // The connection is then checked, if it fails, an echo is sent back to the page stating a connection error.
- if(!empty($_POST))
- {
- $typeofactivity = $_POST['typeofactivity'];
- $employer = $_POST['employer'];
- $date = $_POST['date'];
- $time = $_POST['time'];
- $amount = $_POST['amount'];
- $errorMessage = "";
- if(empty($typeofactivity)) {
- $errorMessage .= "<li>You forgot to enter an activity!</li>";
- }
- if(empty($employer)) {
- $errorMessage .= "<li>You forgot to enter an employer!</li>";
- }
- if(empty($date)) {
- $errorMessage .= "<li>You forgot to select the date!</li>";
- }
- if(empty($time)) {
- $errorMessage .= "<li>You forgot to select the time!</li>";
- }
- if(empty($amount)) {
- $errorMessage .= "<li>You forgot to select the amount of the session!</li>";
- }
- $record_session = "INSERT INTO session_details (typeofactivity, employer, date, time, amount) VALUES ('$typeofactivity', '$employer', '$date', '$time', '$amount')";
- mysqli_query($con, $record_session);
- }
- /** Error reporting */
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- header('Location: main.php#sessionrecordsuccess');
- exit();
- ?>
- <!--********************************RECORD SESSION PAGE SUCCESS************************************-->
- <!--***************************************************************************************-->
- <!--********************************HEADER**********************************************-->
- <div data-role="page" id="sessionrecordsuccess">
- <div data-role="header" data-id="foo1" data-position="fixed">
- <div class='cssmenu'>
- <ul>
- <li class='active'><a href='#home'>Home</a></li>
- <li><a href='#sessionrecord'>Record a Session</a></li>
- <li><a href='#viewsessions'>View Sessions</a></li>
- <li><a href='#email'>E-mail an Invoice</a></li>
- </ul>
- </div>
- </div><!-- /header -->
- <!--********************************HEADER**********************************************-->
- <!--********************************MAIN**********************************************-->
- <div data-role="main" class="ui-content">
- <img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
- <section class="maincontent">
- <h1>Record a session using the form below</h1>
- <P>Session logged successfully! <br>Record another...</p>
- <form method="post" action="record_session.php" id="sessionRecord">
- <fieldset>
- <select name="typeofactivity" id="typeofactivity" data-native-menu="false">
- <option>Type of Session</option>
- <option value="Surf">Surf</option>
- <option value="Coasteer">Coasteer</option>
- <option value="Bodyboard">Bodyboard</option>
- <option value="Cornish Challenge">Cornish Challenge</option>
- </select>
- </fieldset>
- <fieldset>
- <select name="employer" id="employer" data-native-menu="false">
- <option>Employer</option>
- <option value="Newquay Activity Centre">Newquay Activity Centre</option>
- <option value="Coastline Coasteer">Coastline Coasteer</option>
- </select>
- </fieldset>
- <label for="date">Date of Session</label>
- <input type="date" data-clear-btn="false" name="date" id="date" value="">
- <label for="time">Time of Session</label>
- <input type="time" data-clear-btn="false" name="time" id="time" value="">
- <label for="amount">Amount (GBP)</label>
- <input type="number" data-clear-btn="true" name="amount" id="amount" value="">
- <div id="submitbutton">
- <input type="submit" name="formSubmit" value="Submit">
- </div>
- </form>
- </section>
- </div>
- <!--********************************MAIN**********************************************-->
- <!--********************************FOOTER**********************************************-->
- <div data-role="footer">
- <footer class="footer">
- <p>awilliams©</p>
- </footer>
- </div>
- </div>
- <!--********************************FOOTER**********************************************-->
- <!--********************************END OF RECORD SESSION PAGE SUCCESS************************************-->
- <!--***************************************************************************************-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement