Jump to content

PHPTOM

Members
  • Posts

    84
  • Joined

  • Last visited

Posts posted by PHPTOM

  1. Hello, I haven't ran your code. However, I quickly saw that you have used single equals sign in your if statement:

    if(($user_type = "user") && ($is_verified = "1")) {

     

    What you should do is use double equals to create an 'is equal to' condition. For example:

    if($user_type == 'user' && $is_verified == 1) {

  2. Hey,

    Looking to find a solution to something. I have been experimenting making a template engine for a website I am building. How can I search a variable for all occurrences of {VARIABLE} eg. {Username} {Title} {Content} so I can str_replace them.

     

    Thank you

  3. What are your motives for doing this? I don't get what you are trying to achieve by using output buffering. If you want to display the code just put:

    <html>
    <body>
    <center>
    <br/>
    <h1>Apartment Reference #: <?php
    echo $_POST["reference"]; ?><br /></h1>
    <br/>
    <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br />
    <?php echo $_POST["pets"]; ?><br />
    <br/>
    <?php echo $_POST["community"]; ?><br />
    <?php echo $_POST["interior"]; ?><br />
    <?php echo $_POST["amenities"]; ?><br />
    <br/>
    <?php echo $_POST["contact"]; ?><br />
    <a href="<?php
    echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/>
    <br/>
    <br/>
    <br/>
    </body>
    </html>
    

     

    into a blank php file and it will display

  4. <?php ob_start(); ?>
    <html>
    <body>
    <center>
    <br/>
    <h1>Apartment Reference #: <?php
    echo $_POST["reference"]; ?><br /></h1>
    <br/>
    <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br />
    <?php echo $_POST["pets"]; ?><br />
    <br/>
    <?php echo $_POST["community"]; ?><br />
    <?php echo $_POST["interior"]; ?><br />
    <?php echo $_POST["amenities"]; ?><br />
    <br/>
    <?php echo $_POST["contact"]; ?><br />
    <a href="<?php
    echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/>
    <br/>
    <br/>
    <br/>
    </body>
    <?PHP
    $HtmlCode= ob_get_contents();
    ob_end_flush();
    ?>
    

  5. Couple of ideas:

    Use AJAX to submit the form to include both of them in a get statement

     

    Or:

    As the value put something like value="1&delete"

     

    Then you can explode it to form an array

     

    Eg:

     

    <input name="delete[]" type="checkbox" value="1&delete" /> 
    $array = explode("&", $val);
    echo $array[0]; //Value
    echo array[1]; //ID
    

     

    Hope you get the jist

  6. Security reasons. To the other server you could be a malicious hacker. Best way IMO is to do all the logic on server 1 as to whether to upload or not, then use PHP's FTP functions to upload it.

    I've thought of that, the problem though is that files can be up to 5GB in size. If I change the php.ini to allow such big files I think all other (internet) 'friends' may abuse it, that's why I started the home server.

     

    Well protect the page with some kind of username/password? Even htaccess would suffice if it is a small time thing.

  7. Security reasons. To the other server you could be a malicious hacker. Best way IMO is to do all the logic on server 1 as to whether to upload or not, then use PHP's FTP functions to upload it to server 2.

  8. Definitions of programming framework on the Web:

     

        * Programming frameworks are application agnostic, algorithm agnostic and platform agnostic (they help you Program efficiently)

     

    Take a look at CakePHP. Have a read on their website.

  9. To put it bluntly anything using cookies is a security risk. This is just part and parcel of implementing a remember me. The only things I could think of is if the person logs in with the remember me checked:

     

    1) Login with checked

    2) Insert into a remember me table with the IP, ID of user, agent, random auth

    3) Set a cookie with the random auth

    4) check against it all and if it comes back true login to the user ID

     

    Only thing I could think of in the early hours of the morning. I do think this is one of the better methods as you can be remembered on different computers.... eg work and home

  10. in the showarticle.php I have:

    	$article_num = $_GET['cid']; 
      //check if the article number exists, function call
    check_artnum ($makalah_num);
    
    

     

    //the function declaration

    
    function check_artnum ($article_num) {
    $query = mysql_query ("Select * FROM `articles_content` where `num` = '$article_num' ");
    $num_rows = mysql_num_rows($query);
    	if ($num_rows == 0 || $num_rows < 0) {
    		return $article_num = '101';}
    	else {}
    }
    

     

    is the logic and sytanx correct?

    I tried ti write a wrong article number in the URL  it gave me a blank page.

     

    Thank you

     

    This code doesn't actually output to the page, so hence the blank page. Personally I would do this, though I haven't checked that it works:

     

    function check_artnum ($article_num) {
    $query = mysql_query("Select * FROM `articles_content` where `num` = '".$article_num."'");
    $num_rows = mysql_num_rows($query);
    return ($num_rows == 0) ? '101' : $article_num;
    }
    

     

    echo check_artnum($_GET['cid']);
    

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