Jump to content

wright67uk

Members
  • Posts

    454
  • Joined

  • Last visited

Posts posted by wright67uk

  1. Im trying to dynamically generate infomation for a graph.

    I have tested my sql queries, and my graph seperatly, but im not really sure how I put them together.

    I have made an attempt for the 'Driver' Series, (commented below), but as im sure you can see from my code below, my code is in a bit of a mess. Am I getting anywhere?

     

    in the code below, you will see that the different series are already populated with figures.

    I would like to delete the numbers, and replace them with info generated by php/ MySql.

     

    Ive commented below each series, the outcome im looking for.

     

    Any help, advice or suggestions, would be very much appreciated!

     

     

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <?php
    $hostname_connect= "#"; $database_connect= "#";
    $username_connect= "#"; $password_connect= "#";
    $connect_solning = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR);
    @mysql_select_db($database_connect) or die (mysql_error());
    
    $tbl_name = "snag";
    $result = mysql_query("SELECT yard FROM `snag` WHERE club = 'Driver' AND user_id = 1");
    while($row=mysql_fetch_array($result)) {
    $yard=$row["yard"];
    }
    ?>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(function () {
    var chart;
    $(document).ready(function() {
     chart = new Highcharts.Chart({
    	 chart: {
    		 renderTo: 'container',
    		 type: 'line',
    		 marginRight: 130,
    		 marginBottom: 25
    	 },
    	 title: {
    		 text: 'Ranges by Club',
    		 x: -20 //center
    	 },
    	 subtitle: {
    		 text: 'Ranges',
    		 x: -20
    	 },
    	 xAxis: {
    		 categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
    			 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
     /* SELECT sdate FROM snag WHERE user_id = 1 */
    	 },
    	 yAxis: {
    		 title: {
    			 text: 'Score'
    		 },
    		 plotLines: [{
    			 value: 0,
    			 width: 1,
    			 color: '#808080'
    		 }]
    	 },
    	 tooltip: {
    		 formatter: function() {
    				 return '<b>'+ this.series.name +'</b><br/>'+
    				 this.x +': '+ this.y +'';
    		 }
    	 },
    	 legend: {
    		 layout: 'vertical',
    		 align: 'right',
    		 verticalAlign: 'top',
    		 x: -10,
    		 y: 100,
    		 borderWidth: 0
    	 },
    
    
    /* MY ATTEMPT FOR DRIVER SERIES BELOW */		
    
    
     series: [{
    		 name: 'Driver',
    		 data: [<?php echo "$yard, " ?>]
    /* SELECT yard FROM `snag` WHERE club = 'Driver' AND user_id = 1 */
    	 }, {
    		 name: '3 Wood',
    		 data: [-0.2, 0.8, 5.7, 11.3, 7.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
    /* SELECT yard FROM `snag` WHERE club = '3 wood' AND user_id = 1 */
    	 }, {
    		 name: '5 Wood',
    		 data: [-0.9, 0.6, 3.5, 5.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
    /* SELECT yard FROM `snag` WHERE club = '5 wood' AND user_id = 1 */
    	 }, {
    		 name: 'Hybrid',
    		 data: [6.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    /* SELECT yard FROM `snag` WHERE club = 'Hybrid' AND user_id = 1 */
     }, {
    		 name: '3 iron',
    		 data: [4.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 5.8]
    /* SELECT yard FROM `snag` WHERE club = '3 iron' AND user_id = 1 */
     }, {
    		 name: '4 iron',
    		 data: [2.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 6.8]
    /* SELECT yard FROM `snag` WHERE club = '4 iron' AND user_id = 1 */
     }, {
    		 name: '5 iron',
    		 data: [1.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 7.8]
    /* SELECT yard FROM `snag` WHERE club = '5 iron' AND user_id = 1 */
     }, {
    		 name: '6 iron',
    		 data: [3.8, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 8.8]
    /* SELECT yard FROM `snag` WHERE club = '6 iron' AND user_id = 1 */
     }, {
    		 name: '7 iron',
    		 data: [3.6, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 9.8]
    /* SELECT yard FROM `snag` WHERE club = '7 iron' AND user_id = 1 */
     }, {
    		 name: '8 iron',
    		 data: [3.5, 4.1, 5.5, 1.5, 18.9, 13.2, 16.0, 16.8, 14.6, 10.4, 6.4, 4.4]
    /* SELECT yard FROM `snag` WHERE club = '8 iron' AND user_id = 1 */
     }, {
    		 name: '9 iron',
    		 data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    /* SELECT yard FROM `snag` WHERE club = '9 iron' AND user_id = 1 */
     }, {
    		 name: 'P Wedge',
    		 data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    /* SELECT yard FROM `snag` WHERE club = 'P wedge' AND user_id = 1 */
     }, {
    		 name: 'S Wedge',
    		 data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    /* SELECT yard FROM `snag` WHERE club = 'S Wedge' AND user_id = 1 */
    	 }]
     });
    });
    
    });
    </script>
    </head>
    <body>
    <script src="../../js/highcharts.js"></script>
    <script src="../../js/modules/exporting.js"></script>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
    </div>
    </body>
    </html>
    

  2. The below query returns the correct dataset but without carriage returns, have I used "\n" correctly?

     

    
    
    $tbl_name = "snag_score";
    
    
    $result = mysql_query("SELECT * FROM $tbl_name");
    
    
    while($row = mysql_fetch_array($result)) {   
    echo $row['user_id'] . "\t" . $row['total_score']. "\n"; } 
    ?>
    

  3. So more like the below?

    <?php
       session_start();
    
    include 'connection.php';
    
    $insert_query = ("insert into users('name', 'email', 'phone', 'postcode', 'type', 'start', 'user', 'password', 'tac')
    values (
                   " . $_SESSION['name']     . ",
                   " . $_SESSION['email']    . ",
                   " . $_SESSION['phone']    . ",
                   " . $_SESSION['postcode'] . ",
    			" . $_SESSION['type']     . ",
    			" . $_SESSION['start']    . ",
                   " . $_POST   ['user']     . ",
                   " . $_POST   ['password'] . ",
                   " . $_POST   ['tac']      . "   )
                                                    ") or die(mysql_error());
    
    echo "Data Inserted!";
    echo $insert_query;
    
    mysql_query($insert_query); 		
    
    ?>
    

  4. I'm trying to insert some form results into a table. I've tested my connection, and the query echos out fine.

     

    I understand that, I need to sanitize my variables, but for now I'm trying to figure out why nothing gets inserted into my database.

     

    Does my code seem to be ok, or is this most likely down to the way my table has been setup?

     

    <?php session_start();
    
    include 'connection.php';
    
    $insert_query = ("insert into users(name, email, phone, postcode, type, start, user, password, tac) values ( " . $_SESSION['name'] . ", " . $_SESSION['email'] . ", " . $_SESSION['phone'] . ", " . $_SESSION['postcode'] . ", " . $_SESSION['type'] . ", " . $_SESSION['start'] . ", " . $_POST ['user'] . ", " . $_POST ['password'] . ", " . $_POST ['tac'] . " ) ") or die(mysql_error());
    
    echo "Data Inserted!"; echo $insert_query;
    
    mysql_query($insert_query);
    
    ?>
    

  5. I'm new to session variables, and I'm using the code below as an attempt to pass info from 1 page to another as part of a 2 part form.

     

    I'm echoing the variables in the second page but get no values returned.

     

    Below is my initial page, any kind comments as to where I'm going wrong?

     

    <?php
    session_start();
    
    session_register('name');
    session_register('email');
    session_register('phone');
    session_register('postcode');
    session_register('type');
    session_register('start');
    session_register('description');
    
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['email'] = $_POST['email'];
    $_SESSION['phone'] = $_POST['phone'];
    $_SESSION['postcode'] = $_POST['postcode'];
    $_SESSION['type'] = $_POST['type'];
    $_SESSION['start'] = $_POST['start'];
    $_SESSION['description'] = $_POST['description'];
    ?>
    
    <!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" />
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    
       <div id="clientform">
       <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p>
    
    
       <form action="client_start_2.php" method="post">
    
    <p     class="left"><label for="name" class="required">Your Name</label><br>
    <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p>
    
    <p     class="right"><label for="email" class="required">Your Email Address</label><br>
    <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p>
    
    <div style="clear:both" />
    
    <p     class="left"><label for="phone">Your Phone Number</label><br>
    <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p>
    
    <p     class="right"><label for="postcode">Your Full Postcode</label><br>
    <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p>
    
    <div style="clear:both" />
    
    <p      class="left"><label for="type" class="required">Type of works</label><br>
    <select class="dropdown required" id="type" name="type" required="required" tabindex="9">
    <option value=""> Please Select </option>
    <option value="1">Tree Surgery</option>
    <option value="2">Stump Grinding</option>
       <option value="3">Tree Surgery and Stump Grinding</option>
    </select></p>
    
    <p     class="right"><label for="phone">Ideal Start Date</label><br>
    <input class="field" id="start" name="start" placeholder="Your Ideal Start Date" tabindex="5" type="text"></p>
    
    <div style="clear:both">
    
    
    <p        class="left"><label for="question" class="required">Brief Description of Works</label><br>
    <textarea class="textarea required" id="description" name="description" placeholder="Job Description" required tabindex="10"></textarea></p>
    
    <p class="button"><button tabindex="6" type="submit">Submit</button></p>
    
    <div style="clear:both" />
    
    </form>
    
       </div>
    </body>
    </html>
    

     

  6. I'm trying out session cookies for the first time, and I have run into some troubles.

    Im recieving the following errors below;

     

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at filelocation/filename:3) in filelocation/filename on line 4

     

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at filelocation/filename:3) in filelocation/filename on line 4

     

    Any help would be great!

     

     

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    session_start();
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Tree Quoter</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="content_slider_style.css" />
    <link rel="stylesheet" type="text/css" href="form.css" />
    <script type="text/javascript" src="js/jquery.1.3.2.min.js" ></script>
    <script type="text/javascript" src="js/jquery-ui.min.js" ></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000, true);
    });
    </script>
    </head>
    <body>
    <div id="templatemo_body_top">
    <div id="templatemo_body_bottom">
    <div id="templatemo_wrapper">
    <div id="templatemo_header">
     <div id="site_title">
    	 <h1><a href="http://www.treequoter.co.uk"><strong>Tree Quoter</strong><span>Expert tree surgeons, competitive quotes</span></a></h1>
     </div> <!-- end of site_title -->
    </div>
    
    <div id="templatemo_menu">
     <ul>
    	 <li><a href="index.html" class="current">Home</a></li>
    	 <li><a href="services.html">Get quotes</a></li>
    	 <li><a href="blog.html">Get Clients</a></li>
    	 <li><a href="gallery.html">More info</a></li>
    	 <li><a href="contact.html">Contact Us</a></li>
     </ul>	
    </div> <!-- end of templatemo_menu -->
    
    <div id="templatemo_main_wrapper_01">
    <div id="templatemo_main_wrapper_02">
    <div id="templatemo_main_wrapper_03">
    <div id="templatemo_main">
    
    
    <div id="templatemo_slider">
    
    <div id="featured" >
    <ul class="ui-tabs-nav">
    	 <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"><img src="images/content_slider/image1-small.jpg" alt="" /><span>Professional tree felling by expert tree surgeons</span></a></li>
    	 <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><img src="images/content_slider/image2-small.jpg" alt="" /><span> Tree removal, a section at a time</span></a></li>
    	 <li class="ui-tabs-nav-item" id="nav-fragment-3"><a href="#fragment-3"><img src="images/content_slider/image3-small.jpg" alt="" /><span>Brush chipping and recycling</span></a></li>
    	 <li class="ui-tabs-nav-item" id="nav-fragment-4"><a href="#fragment-4"><img src="images/content_slider/image4-small.jpg" alt="" /><span>
    	 Stump Grinding, creating new spaces</span></a></li>
     </ul>
     <!-- First Content -->
     <div id="fragment-1" class="ui-tabs-panel" style="">
     <img src="images/content_slider/image1.jpg" alt="" />
     <div class="info" >
    <h2><a href="#" >Professional Tree Felling</a></h2>
    <p>An expert tree surgeon will be able to safely fell a diseased or dangerous tree, sometimes even in confined spaces.... <a href="#" >read more</a></p>
    </div>
     </div>
     <!-- Second Content -->
     <div id="fragment-2" class="ui-tabs-panel ui-tabs-hide" style="">
    <img src="images/content_slider/image2.jpg" alt="" />
    <div class="info" >
    <h2><a href="#" >Tree Removal</a></h2>
    <p>Sometimes the only safe way to remove a tree is to take away a section at a time, roping as we go.... <a href="#" >read more</a></p>
    </div>
     </div>
     <!-- Third Content -->
     <div id="fragment-3" class="ui-tabs-panel ui-tabs-hide" style="">
    <img src="images/content_slider/image3.jpg" alt="" />
    <div class="info" >
    <h2><a href="#" >Brush Chipping</a></h2>
    <p>Brush cut from your tree is often chipped and taken away. This can then be spread over garden beds or burnt in power stations.... <a href="#" >read more</a></p>
    	 </div>
     </div>
     <!-- Fourth Content -->
     <div id="fragment-4" class="ui-tabs-panel ui-tabs-hide" style="">
    <img src="images/content_slider/image4.jpg" alt="" />
    <div class="info" >
    <h2><a href="#" >Stump Grinding</a></h2>
    <p>Post tree removal, people often ask for their stump to be removed, creating extra space in their bed, or simply for aesthetics.... <a href="#" >read more</a></p>
    	 </div>
     </div>
    </div>
    </div> <!-- end of templatemo_slider -->
    
    <div id="clientform">
    <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p>
    
    <?php
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['email'] = $_POST['email'];
    $_SESSION['phone'] = $_POST['phone'];
    $_SESSION['postcode'] = $_POST['postcode'];
    $_SESSION['type'] = $_POST['type'];
    $_SESSION['start'] = $_POST['start'];
    ?>
    
    <form action="client_start_2.php" method="post">
    <p class="left"><label for="name" class="required">Your Name</label><br>
    <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p>
    <p class="right"><label for="email" class="required">Your Email Address</label><br>
    <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p>
    <div style="clear:both" />
    <p class="left"><label for="phone">Your Phone Number</label><br>
    <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p>
    <p class="right"><label for="postcode">Your Full Postcode</label><br>
    <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p>
    <div style="clear:both" />
    <p class="left"><label for="type" class="required">Type of works</label><br>
    <select class="dropdown required" id="type" name="type" required="required" tabindex="9">
    <option value=""> Please Select </option>
    <option value="1">Tree Surgery</option>
    <option value="2">Stump Grinding</option>
    <option value="3">Tree Surgery and Stump Grinding</option>
    </select></p>
    <p class="right"><label for="phone">Ideal Start Date</label><br>
    <input class="field" id="start" name="start" placeholder="Your Ideal Start Date" tabindex="5" type="text"></p>
    <div style="clear:both">
    
    <p class="left"><label for="question" class="required">Brief Description of Works</label><br>
    <textarea class="textarea required" id="description" name="description" placeholder="Job Description" required tabindex="10"></textarea></p>
    <p class="button"><button tabindex="6" type="submit">Submit</button></p>
    <div style="clear:both" />
    </form>
    
    </div> <!-- end of clientform -->
    
    </div></div></div></div></div></div></div>
    <div id="templatemo_footer">
    
     <a href="index.html" class="current">Home</a> | <a href="services.html">Get Quotes</a> | <a href="blog.html">Get Clients</a> | <a href="gallery.html">More Info</a> | <a href="contact.html">Contact Us</a> <br /><br />
     Copyright © 2012 <a href="#">Tree Quoter</a> | Designed by <a href="http://www.websites.cx" target="_parent">Websites.cx</a>
    
    </div> <!-- end of templatemo_footer -->
    </div>
    </div> <!-- end of wrapper -->
    </div>
    </div>
    </body>
    </html>
    

  7. I have a html form which is spread over two pages.

    What is the best way to collect information from the two pages and insert them into a single mysql database?

     

    Do I carry the results from the first form over to client_start_2.html and then process the the parts of the form together?

    Or is best to process the halves of the form seperately somehow?

     

    <div id="clientform">
    <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p>
    <form action="client_start_2.html" method="post">
    <p class="left"><label for="name" class="required">Your Name</label><br>
    <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p>
    <p class="right"><label for="email" class="required">Your Email Address</label><br>
    <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p>
    <div style="clear:both" />
    <p class="left"><label for="phone">Your Phone Number</label><br>
    <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p>
    <p class="right"><label for="postcode">Your Full Postcode</label><br>
    <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p>
    <div style="clear:both" />
    <p class="left"><label for="type" class="required">Type of works</label><br>
    <select class="dropdown required" id="type" name="type" required="required" tabindex="9">
    <option value=""> Please Select </option>
    <option value="1">Tree Surgery</option>
    <option value="2">Stump Grinding</option>
    <option value="3">Tree Surgery and Stump Grinding</option>
    </select></p>
    <p class="right"><label for="phone">Ideal Start Date</label><br>
    <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="5" type="text"></p>
    <div style="clear:both">
    <p class="left"><label for="question" class="required">Brief Description of Works</label><br>
    <textarea class="textarea required" id="question" name="question" placeholder="Your Question" required tabindex="10"></textarea></p>
    <p class="button"><button tabindex="6" type="submit">Submit</button></p>
    <div style="clear:both" />
    </form>
    

     

    and then on client_start_2.html;

     

    <div id="clientform">
    <p>Nearly there... Please choose a username and password, then were all done! <br/><br/></p>
    <form action="my-processing-page.php" method="post">
    <p><label for="name" class="required">Username</label><br>
    <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p>
    <div style="clear:both" />
    <p class="left"><label for="password" class="required">Password</label><br>
    <input class="field required" id="password" name="password" placeholder="password" required tabindex="2" type="text"></p>
    <p class="right"><label for="confirm">Confirm Password</label><br>
    <input class="field" id="confirm" name="confirm" placeholder="confirm password" tabindex="3" type="text"></p>
    <div style="clear:both" />
    <p class="left">Do you agree to the terms and conditions? <br/><input type="radio" value="Yes" name="Yes" > Yes
    		 <input type="radio" value="No" name="No"> No
    </p>
    <p class="button"><button tabindex="6" type="submit">Submit</button></p>
    <div style="clear:both" />
    </form>	
    

     

    Many thanks

  8.  

    Im trying to get this form to work, however the email I receive after the form is submitted contains none of the users input. Can anyone see a reason for this?

     

     

     

    <?php

    if(isset($_POST['name'])) {

     

    $to = "myemail@hotmail.co.uk"; // Your email

    $subject = "you have received a new mobile website message"; // Subject

     

    $name_field = $_POST['name'];

    $email_field = $_POST['email'];

    $message = $_POST['message'];

     

    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

    $headers = "From:" . $name_field;

     

    if(@mail($to, $subject, $body, $headers)) echo "<h1>Thank you for your message!</h1>";

    else echo "<h1>Email has been not sent!</h1>";

     

    } else {

     

    header('Location: contact.html');

     

    }

    ?>

     

    <script>

    <!--

    timeout = '2000'; // milliseconds/1000th of a sec

    window.onload = setTimeout(myRedirect, timeout); // ensure we load the whole page

     

    function myRedirect() {

     

    window.location = "contact.html";

    }

    //-->

    </script>

    [Code]

  9. How can i load a file based on the screen size of my device?

     

     

    <div data-role="page" id="one">
    <?php include("header.php") ?>
    <!-------------------------------- container Start ---------------------------------------->
    <div class="container">
    <div class="containerInner">
    
    <?php include("nav.php") ?>
    <?php include("banner.php") ?>
    <?php include("form.php") ?>
    </div>
    </div>
    <!-------------------------------- container End ---------------------------------------->
    <?php include("footer.php") ?>
    </div>
    
    

     

    So instead of <?php include("form.php") ?> I would like to do <?php include("formSMALL.php") ?>

     

    I would want any user with a screen width greater than 240px to be presented with form.php and any user with a screen width of 240px or smaller to be presented with formSmall.php

     

    I have the below javascript to detect the screen sizes, however im unsure of how to combine the two.

     

    Please, any help will be very much appreciated.

     

     

    Heres the javascript I have for screen detection;

     

    <!DOCTYPE html>
    <html>
    <body>
    <script type="text/javascript">// <![CDATA[
    document.write("Total Width: " + screen.width);
    document.write("<br/> Total Height: " + screen.height);
    // ]]></script>
    script>
    </body>
    </html>
    

  10. Would you say that this code is safe from SQL injection?

    If not, then why?

     

    <?php
    if ($_SERVER['REQUEST_METHOD']=='POST'){
    $con = mysql_connect( "###","###","###" );
    if (!$con) { die('Could not connect: ' . mysql_error()); }
    mysql_select_db("###", $con);
    $n = mysql_real_escape_string($_POST['name']);
    $e = mysql_real_escape_string($_POST['email']);
    $sql="INSERT INTO waiting (name, email) VALUES('$n','$e')";
    if (!mysql_query($sql,$con)){ die('Error: ' . mysql_error()); }
    echo "Thankyou! We will be in touch soon.";
    mysql_close($con);
    }
    ?>
    
    
    <?php if ($_SERVER['REQUEST_METHOD']<>'POST'){ ?>
    <p> This website is under construction!<br />
    Enter your details and we will get back to you as soon as we are all done.<br />
    <br />
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    Name: <input type="text" name="name" /><br /><br />
    Email: <input type="email" name="email" />
    <br /><br />
    <input type="submit" value="Submit" />
    </form></p>
    
    <?php } ?>
    

  11. What would be the best way to sanitize the simple form below?

    • FILTER_SANITIZE_EMAIL
    • FILTER_VALIDATE_EMAIL
    • (isset($_REQUEST['email']))

    Ive seen the above, but to be quite honest im not sure where or how they would go.

    Ive had a play around but im not getting very far!

     

    Any help would be really great!

     

    <div id="box">
    <?php
    $con = mysql_connect("userdb,pw");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db("database", $con);
    $sql="INSERT INTO tablename (name, email)
    VALUES
    ('$_POST[name]','$_POST[email]')";
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Thankyou! We will be in touch soon.";
    
    mysql_close($con);
    ?>
    
    </div>
    

  12. Hi Christian,

     

    just checked this is all i get;

     

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/o/o/myaccounthere/html/websitescx/contact.php:1) in /home/content/w/o/o/woodside09/html/websitescx/contact.php on line 22

  13. Firstly  - Maxudaskin, thankyou for the explanation, I do need to set aside some time to read up on this!

     

    DavidAM -

    Now im really puzzled - lol

     

    The mail does send but

    The header error does still remain

    Warning: Cannot modify header information - headers already sent by ..... on line 22. (labelled)

     

    <?php 
    $to = "edward_t_wright@hotmail.co.uk";
    $from = $_REQUEST['Email'] ; 
    $name = $_REQUEST['Name'] ;  //not in use, keep for other form
    $headers = "From: $from"; 
    $subject = "Web Contact Data"; 
    
    $fields = array(); 
    $fields{"Name"} = "Name";   //not in use, keep for other form
    $fields{"Email"} = "Email"; 
    $fields{"Phone"} = "Phone"; 
    $fields{"Message"} = "Message"; 
    
    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ 	$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
    
    if($from == '') {
      print "You have not entered an email, please go back and try again";} 
    else { 
      $send = mail($to, $subject, $body, $headers); 
      $send2 = mail($from, $subject2, $autoreply, $headers2); 
      if($send) {
        header( "Location: http://www.websites.cx/indextest.html" ); ##Line22
        exit();
        ## ALWAYS INCLUDE AN EXIT AFTER A HEADER Redirect. Otherwise, the PHP engine will continue executing code.
    }  else {
        print "We encountered an error sending your mail, please notify webmaster@YourCompany.com";
      }
    }
    ?> 

  14. Thankyou for the replies.

    By doing

    
    $send = mail($to, $subject, $body, $headers); 
      $send2 = mail($from, $subject2, $autoreply, $headers2); 
      if($send) {
        header( "Location: http://www.websites.cx/indextest.html" );
        exit();

     

    then surely im outputting html, before the header?  please excuse me if im being silly.

  15. thanks for the reply.

     

    Thats what I thought I was doing but I cant figure how I would handle

     

    if($send) 
    {header( "Location: http://www.websites.cx/indextest.html" );} 
    

    if

    if($from == '') {print "You have not entered an email, please go back and try again";} 
    else { 
    $send = mail($to, $subject, $body, $headers); 
    $send2 = mail($from, $subject2, $autoreply, $headers2); 
      }
    

    provides the value for $send. 

  16. Ok Ive got it.  No html or white space above the header.

    Thankyou for the replies!

     

    Ive moved the two if/else if's around;

     

    
    <?php 
    $to = "edward_t_wright@hotmail.co.uk";
    $from = $_REQUEST['Email'] ; 
    $name = $_REQUEST['Name'] ;  //not in use, keep for other form
    $headers = "From: $from"; 
    $subject = "Web Contact Data"; 
    
    $fields = array(); 
    $fields{"Name"} = "Name";   //not in use, keep for other form
    $fields{"Email"} = "Email"; 
    $fields{"Phone"} = "Phone"; 
    $fields{"Message"} = "Message"; 
    
    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ 	$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
    
    $headers2 = "From: edward_t_wright@hotmail.co.uk"; 
    $subject2 = "Thank you for contacting us"; 
    $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 24 hours.";
    
      if($send) 
    {header( "Location: http://www.websites.cx/indextest.html" );} 
    else 
    {print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; } 
    
    
    if($from == '') {print "You have not entered an email, please go back and try again";} 
    else { 
    $send = mail($to, $subject, $body, $headers); 
    $send2 = mail($from, $subject2, $autoreply, $headers2); 
      }
    
    ?> 
    

    I no longer get the header error.

     

    The problem now is that $send is empty?

     

    so I get my error message ;  "We encountered an error sending your mail, please notify webmaster@YourCompany.com";

    if i move

    $send = mail($to, $subject, $body, $headers); 
    $send2 = mail($from, $subject2, $autoreply, $headers2); 
    

     

    to above the if's ill get the header error again.  Whats the best way to juggle this about?

  17. Hi, I have a fully funtioning form, with the exception of the re-direct at the end.

     

    I get the following error message;

     

    Warning: Cannot modify header information - headers already sent by (output started at filelocation/contact.php on line 25)

     

    Here is contact.php;

     

    <?php 
    $to = "edward_t_wright@hotmail.co.uk";
    $from = $_REQUEST['Email'] ; 
    $name = $_REQUEST['Name'] ;  //not in use, keep for other form
    $headers = "From: $from"; 
    $subject = "Web Contact Data"; 
    
    $fields = array(); 
    $fields{"Name"} = "Name";   //not in use, keep for other form
    $fields{"Email"} = "Email"; 
    $fields{"Phone"} = "Phone"; 
    $fields{"Message"} = "Message"; 
    
    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ 	$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
    
    $headers2 = "From: edward_t_wright@hotmail.co.uk"; 
    $subject2 = "Thank you for contacting us"; 
    $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 24 hours.";
    
    if($from == '') {print "You have not entered an email, please go back and try again";} 
    else { 
    $send = mail($to, $subject, $body, $headers); 
    $send2 = mail($from, $subject2, $autoreply, $headers2); 
    if($send) 
    {header( "Location: http://www.websites.cx/indextest.html" );} 
    else 
    {print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; } 
    }
    ?> 
    

     

    Any tips would be great?

  18. The below script generates an infinate loop, hangs, and creates hundeds of mysql records (all duplicates), can you see anything that stands out in my script, that coul dbe causing this?

     

    I want to see wether or not I should rule out the script as the cause.

     

    index.php

    <?php
    
    session_start();
    
    if (!empty($_SESSION)) {
        header("Location: index.php");
    }
    mysql_connect(CONNECTS FINE) or die(mysql_error());
    mysql_select_db('DBNAME') or die(mysql_error());
    
    # require library
    require("facebook.php");
    
    # Creating the facebook object
    $facebook = new Facebook(array(
                'appId' => 'appid', //hidden for forum
                'secret' => 'secretnumber', //hidden for forum
                'cookie' => true
            ));
    
    # check active session
    $session = $facebook->getSession();
    
    
    if (!empty($session)) {
        # session active, get user id (getUser()) and user info (api->('/me'))
        try {
            $uid = $facebook->getUser();
            $fb_access_token=$session['access_token'];
            $url = $facebook->getLoginUrl(array(
                'req_perms' => 'email,status_update,publish_stream'
                    ));
            $user = $facebook->api('/me');
            $photolink = 'http://graph.facebook.com/'.$user['id'].'/picture?type=square';
            $param = array(
                'method' => 'users.getInfo',
                'uids' => uid,
                'fields' => 'pic_big'
            );
            $users_getinfo = $facebook->api($param);
        } catch (Exception $e) {
    
        }
    
        if (!empty($user)) {
            # active session, check if already registered the user
            $query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND oauth_uid = " . $user['id']);
            $result = mysql_fetch_array($query);
    
    
            # If not, add it to the database
            if (empty($result)) {
                $query = mysql_query("INSERT INTO users (oauth_uid, oauth_provider, username, first_name, last_name, email, pic_square) VALUES ('facebook', {$user['id']}, '{$user['name']}', '{$user['first_name']}', '{$user['last_name']}','{$user['email']}', '".$photolink."')");
                $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());
                $result = mysql_fetch_array($query);
            }
    
    
            // variables in the session 
            $_SESSION['id'] = $result['id'];
            $_SESSION['oauth_uid'] = $result['oauth_uid'];
            $_SESSION['oauth_provider'] = $result['oauth_provider'];
            $_SESSION['username'] = $result['username'];
        } else {
            # if error, kill the script
            die("There was an error.");
        }
    
        $api_call = array(
            'method' => 'users.hasAppPermission',
            'uid' => $uid,
            'ext_perm' => 'publish_stream'
        );
        $can_post = $facebook->api($api_call);
        if ($can_post) {
            # post it! 
            $facebook->api('/' . $uid . '/feed', 'post', array(
                'message' => 'This is intercake test message',
                'name' => 'Random Contest',
                'description' => 'Participate in Random Contest and Win prizes.',
                'caption' => 'WIN prizes by suggesting us a Slogan for our new Random App!',
                'picture' => 'http://www.masudonline.net/camry/headar.jpg',
                'link' => 'http://apps.facebook.com/camryslgn/'
            ));
            echo 'Posted!';
        } else {
            die('Permissions required!');
        }
    } else {
        # no active session, generate one
        $login_url = $facebook->getLoginUrl();
        header("Location: " . $login_url);
    }
    
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.