Jump to content

shocker-z

Members
  • Posts

    864
  • Joined

  • Last visited

Posts posted by shocker-z

  1. <?php
    $check=mysql_query("SELECT * FROM table WHERE userid = '".$userid."' AND field IS NULL");
    $count=mysql_num_rows($check);
    If ($count == 0) {
      $SQL = "INSERT into TABLE (field) VALUES ('{$_POST['value']}') WHERE userid = '$userid'"
    } else {
      $SQL = "UPDATE table SET value = VALUE ('{$_POST['newvalue']}') WHERE userid = '$userid'" 
    }
    ?>
    

     

    untested and a bit rushed but give it a try

     

    Liam

  2. Not so much insecure as just totaly pointless. I can understand a text message, but when access the internet to log into your email to send an email to receive an email with your balance when you could just log into the site and click balance.

     

    If you really want to go ahead with it then you would have to look into using a mailserver with a mysql database (or another accessable database) and search through the emails on some sort of cron job for emails with balance in the subject.

     

    I read up about phones and this can be done on linux system by connecting an old nokia phone by database and text messages are stored in a MySQL databae and you would search that.

     

    still which ever way as said it is insecure and the email side of it is more work then just logging into your site and clicking on balance.

     

    EDIT: l0ve2hat3 I did use some sence and guess you wasn't a bank. but it was kind of a bad example lol

     

    regards

    Liam

  3.  

    An email to SQL??

     

    Not really possible without running some kind of external process launch from outlook or somthing but even then you have to sent the email data to SQL.

     

    could you explain more of what your thinking please?

     

    regards

    Liam

  4. being as PHP is server-side i cant see that being possible.

     

    However you could look at using hosts instead of IP?

     

    $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

     

    you could strip it down to local exchange but then you still have possibility of someone getting in who shouldn't. how sencitive is the data?

     

    Regards

    Liam

  5. It should still be erroring out to be honest as i missed the second usage of $_GET['']

     

    Your final code should be

    <?php
    $dblink = mysql_connect("localhost","username", "password") or die('Error: '.mysql_error ());
    mysql_select_db("database");
    $result = mysql_query("select * from tablename where sku='".$_GET['sku']."'") or die('Error: '.mysql_error ());
    $row = mysql_fetch_array($result);
    $link = $row['link'];
    mysql_query("update tablename set clicks=clicks+1 where sku='".$_GET['sku']."'");
    header('Location: $link');
    mysql_free_result($result);
    mysql_close($dblink);
    ?>

     

     

    Remember to put your code within code brakets (the hash symbol) as this makes it easier to read and diagnose.

     

     

    Regards

    Liam

  6. Try this mate

     

    <?php
    $dblink = mysql_connect("localhost","username", "password") or die('Error: '.mysql_error ());
    mysql_select_db("database");
    $result = mysql_query("select * from tablename where sku='".$_GET['sku']."'") or die('Error: '.mysql_error ());
    $row = mysql_fetch_array($result);
    $link = $row["link"];
    mysql_query("update tablename set clicks=clicks+1 where sku=''$_GET['sku']''");
    header("Location: $link");
    mysql_free_result($result);
    mysql_close($dblink);
    ?>

     

    change the $_GET so it's outside the ""

     

    Regards

    Liam

  7. I.m creating a dynamic query to pull out workbooks from my database the table structure is below.

     

    Table: curricworkbooks

    Columns: ID, curric, assessment, topic, workbook, filename

     

    Example data

    [iD]	[curric]	[assessment]	[topic]		[workbook]	[filename]
    1	N1/E1.1 	Numeracy E1	Count		1		workbooks/Num Entry 1/Unit 1/04 N1E1.1-3 Worksheets Num.pdf
    10	MSS1/E1.6	Numeracy E1	Capacity 	13		workbooks/Num Entry 1/Unit 13/04 MSS1E1.6 Worksheets Num.pdf
    100	MSS1/L1.7	Numeracy L1	Conversions	14		workbooks/Numeracy Level 1/wkbk_14 AoN L1 2D 3D & Scale.pdf
    

     

    So my system will output each workbook in a table which works fine. using thsi query

     

    SELECT distinct(curricworkbooks.filename),workbook FROM curricworkbooks WHERE assessment = 'Literacy E2' AND workbook IS NOT NULL ORDER BY workbook ASC

     

    but i need to also select the ID field from the table, so i thought the query would be somthing like this:

     

    SELECT distinct(curricworkbooks.filename),workbook, ID FROM curricworkbooks WHERE assessment = 'Literacy E2' AND workbook IS NOT NULL ORDER BY workbook ASC

     

    But when i use that query i get non distinct results. I need the distinct on filename as there can be multiple curriculum reference per each workbook which can relate to the same file (Trust me just beleive me on this on the structure is totaly unlogical but it's data that im unable to change.)

     

    All support greatlt appreciated.

     

    Posted simular to this yesterday but think the site got restored again.

     

    regards

    Liam

  8. Hi,

     

    Brief:

    I have a database table with the following columns: ID, curric, assessment, topic, workbook and filename

    This table is used to pull out workbooks for certain assessment levels of the curriculum. What im trying to do is select all records from curricworkbooks table where the filename field is distinct and assessment = 'Literacy L1' My current query below.

     

    SELECT distinct(curricworkbooks.filename),workbook FROM curricworkbooks WHERE assessment = 'Literacy E2' AND workbook IS NOT NULL ORDER BY workbook ASC

     

    This works fine but i also need to pull out the ID yet when i change my query to:

     

    SELECT distinct(curricworkbooks.filename),workbook,ID FROM curricworkbooks WHERE assessment = 'Literacy E2' AND workbook IS NOT NULL ORDER BY workbook ASC

     

    It doesn't filter by distinct and therefore I end up with multiple results for the same workbook.

     

    The reason for the duplicate workbooks is that there are different curriculum references.

     

    Regards

    Liam

     

  9. You cant sent headers after white spaces e.g. any html code will make the header fail.

     

    I usually use meta tage refresh to redirect people when im unable to use header.

     

    also why are you wanting to show html but direct people immediatly also? It doesnt make sence as they would never see the output in the first place.

     

    I use the meta refresh on account created pages to redirect after 10 secs.

     

     

    Regards

    Liam

  10. Your missing a semi colon

     

     

    array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>"") // make the first row blank, 

     

    needs to be

     

    array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>""); // make the first row blank, 

     

    Also you haven't set the array to a variable therefore this is doing nothing at all!

     

    Regards

    Liam

  11. Try this as it will return your error

     

    <?php
    include 'config.php';
    include 'opendb.php';
    
    $query  = "SELECT addr, rent, frontimg, desc, advdesc, addimg1, addimg2, addimg3 FROM properties";
    $result = mysql_query($query) or die(mysql_error());
    
    while(list($addr,$rent,$frontimg,$desc,$advdesc,$addimg1,$addimg2,$addimg3)= mysql_fetch_row($result))
    {
        echo "Address :$addr
    " .
             "Rent PCM : $rent
    " .
             "Front Image : $frontimg
    " .
             "Description : $desc
    " .
             "Advanced Description : $advdesc
    " .
             "Additional Image 1 : $addimg1
    " .
             "Additional Image 2 : $addimg2
    " . 
             "Additional Image 3 : $addimg3
    
    ";
    }
    
    include 'closedb.php';
    ?> 

     

     

    regards

    Liam

  12. CURDATE() doesnt need to be wrapped in quotes as it's a built in mysql function.

     

    <?
    $sql="INSERT INTO News (Date, Title, Content, Image)
    VALUES
    (CURDATE(),'"mysql_real_ escape_string($_POST['title'])"','"mysql_real_ escape_string($_POST['content'])"','"mysql_real_ escape_string($_POST['image'])"')";
    
    if (!mysql_query($sql,$dbh))
      {
      die('Error: ' . mysql_error());
      }
    echo "News item added, thanks!";
    
    mysql_close($dbh)
    ?>

     

    I've also added mysql_real_ escape_string() to help protect you against a few attacks that can be done.

     

    Regards

    Liam

  13. I would use

     

        echo "<input type = 'checkbox' name="checkbox[]" value="The value you want e.g. ID">" . "We can supply this";

     

    That will create an array called $_POST['checkbox'] then use a foreach to loop through the data

     

    foreach ($_POST['checkbox'] as $ID) {
    rcho $ID;
    }

     

     

    Regards

    Liam

  14. I use a mailer class called php mailer http://phpmailer.codeworxtech.com/

     

    Then using this code

     

      
    <?php
    $mail = new PHPMailer();
    
      $mail->IsSMTP();
      $mail->Host     = "127.0.0.1";
      $mail->From     = "youremail@address.com";
      $mail->FromName = "Your email name";
      $mail->AddAddress($emailaddress,$name);
      $mail->AddReplyTo("youremail@address.com","Your email name");
    //  $mail->AddEmbeddedImage('E:/liam/logo/logo.gif','logo','logo.gif');
      $mail->WordWrap = 50;
      $mail->IsHTML(true);
      $mail->Subject  =  "BKSB website results";
      $body=file_get_contents('C:/php/includes/email.html');
      $mail->Body    = $body;
    
      if(!$mail->Send()) {
       echo "Message was not sent <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
      }
    ?>

     

     

    That will do the trick i've commented out the bit where i attach my logo as not sure if you want this, however if you do then to insert the image attached called logo use this in your html file.

     

    <IMG SRC="cid:bksblogo">

     

    Regards

    Liam

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