Jump to content

SyncViews

Members
  • Posts

    75
  • Joined

  • Last visited

    Never

Posts posted by SyncViews

  1. The one I got from that p[age is basicle the same as mine and still isn't working for me :(

     

    mine:

    $allowed = preg_match("|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$|i", $string);

     

    the one I made useing the sites examples:

    $allowed = preg_match("|$[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$|i", $string);

     

    Mayby it's my php code? But if thats the case whyt would both the user name and password ones work...

  2. Ive got this validation code

     

    function valid($string, $type)
    {
    switch ($type)
    {
    	case "name":
    		$allowed = preg_match("|^[A-Z0-9\ _]{3,16}$|i", $string);
    		break;
    
    	case "password":
    		$allowed = preg_match("|^[A-Z0-9_]{6,40}$|i", $string);
    		break;
    
    	case "email":
    		$allowed = preg_match("|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z.]{2,6}$|i", $string);
    		break;
    }
    return ($allowed);
    }
    

    1) For the password one. How do I make it so it allows 6 or more charecters?

     

    2)For e-mails it always returns false. Why is this?

  3. How do I get those rounded edges that many sites have around parts of the layout.

     

    Ive looked at the html for serval sites. Many seem to have a normal div with a solid background colour and i'm not sure how there getting the edges :(

     

    An example would be the phpbb homepage. The main page is on a block with round edges but I can't see how this works. I found this in the css code but I can't see how it works but the page seems to be within this object. (the background image doesn't help either as it just seems to be for the shading effect...)

     

    #wrap {

    width: 910px;

    background: #FFFFFF url("http://static.phpbb.com/theme/images/bg_body.gif") repeat-y 0 0;

    margin: 10px auto;

    text-align: left;

    padding: 0;

    }

  4. yeah. But the good thing is it also means if a hacker somehow gets the md5 hashes from the database they are unlikly to ever get the exact password (partly because there are more than one combinations that give the eact same hash value) so while that might let them into your website it's unlikly that they can get into other websites with the same users (because so many people use the same password on almost every forum, site etc they register for)

  5. Still havn't solved this :(

     

    <?php
    $file_full   = 'images/mytrain.jpg';
    $file_full2  = 'images/mytrain2.png';
    $file_thumb  = 'mytrain.jpg';
    $file_thumb2 = 'mytrain.png';
    
    
    $image_full  = imagecreatefromjpeg ($file_full);
    $image_thumb = imagecreatetruecolor(400, 300);
    
    $image_image_x = imagesx($image_full);
    $image_image_y = imagesy($image_full);
    imagecopyresampled ($image_thumb, $image_full, 0, 0, 0, 0, 400, 300, $file_image_x, $file_image_y);
    
    imagejpeg($image_thumb, $file_thumb);
    imagepng ($image_thumb, $file_thumb2);
    imagepng ($image_full, $file_full2);
    imagedestroy ($image_full);
    imagedestroy ($image_thumb);
    ?>
    <img src="<?=$file_full?>">
    <img src="<?=$file_thumb?>">
    <img src="<?=$file_thumb2?>">
    <img src="<?=$file_full2?>">
    

     

    The tumbnails just show up black while th other images work...I presume it is that the copy/resise doesn't work but I can't see anytrhing wrong with it :(

     

    Also is there anyway to get a useful error with thse functions? eg eith  the mysql_ functions you can use mysql_error() to get a pretty usful error message if something fails?

  6. no i'm not but it was playing up without the ./ as well...

     

    ive aslso got this on the page so I know the paths are correct...

     

    <img src="<?=$file_full?>">

    <img src="<?=$file_thumb?>">

    <img src="<?=$file_thumb2?>">

     

     

    EDIT: also if the path is wrong i get this followed by another 5 or 6 errors

    Warning: imagecreatefromjpeg(/images/mytrain.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory...

  7. Why does this create a black image?

    <?php
    $file_full   = './images/mytrain.jpg';
    $file_thumb  = './images/thumbnails/mytrain.jpg';
    $file_thumb2 = './images/thumbnails/mytrain.png';
    
    $image_full  = imagecreatefromjpeg ($file_full);
    $image_thumb = imagecreatetruecolor(400, 300);
    
    $image_image_x = imagesx($image_full);
    $image_image_y = imagesy($image_full);
    
    imagecopyresampled ($image_thumb, $image_full, 0, 0, 0, 0, 400, 300, $file_image_x, $file_image_y);
    
    imagejpeg($image_thumb, $file_thumb, 80);
    imagepng($image_thumb, $file_thumb2, 5);
    imagedestroy ($image_full);
    imagedestroy ($image_thumb);
    ?>
    

  8. That still doesn't work. If one section is twice the size of the other it doesn't display the border all the way down. I need it so the "height" of both sections is the same as the largest of the two. But there is no way I can no inadvance which of the two will be larger :(

     

    @phpQuestioner

    With that I might as well just use tables seeing as your giving the divs table properties there... I'm trying to learn how to make multi colume tabless websites...

  9. How can I do something like this in css without tables?

    <table style="border-style:solid; border-color:#AAAAAA; border-width:1px">
    <tr>
      <td width="40%" valign="top" style="border-right-style:solid; border-right-color:#EDEDED; border-right-width:1px">
       <h1>LEFT SECTION</h1>
      </td>
      <td width="55%" valign="top" style="border-left-style:solid;  border-left-color:#EDEDED;  border-left-width:1px" >
       <h1>RIGHT SECTION</h1>
      </td>
    </tr>
    </table>
    

     

    I tried the below but that doesn't work :(

    CSS:

    div#body
    {
    border-style: solid;
    border-width: 1px;
    border-color: #AAAAAA;
    background-color: #BBBBBB;
    }
    
    div#body_left
    {
    border-right-style: solid;
    border-right-width: 1px;
    border-right-color: #EDEDED;
    float: left;
    width: 35%;
    height: 100%;
    }
    
    div#body_right
    {
    border-left-style: solid;
    border-left-width: 1px;
    border-left-color: #EDEDED;
    margin-left: 35.5%;
    height: 100%;
    }
    

    HTML:

    <div id="body">
    <div id="body_left">
      <h1>LEFT SECTION</h1>
      <h3>MORE TEXT</h3>
    </div>
      
    <div id="body_right">
      <h1>RIGHT SECTION</h1>
    </div>
    </div>
    

  10. I think the problem is he doesn't want the files to be based on his site but to be "sold" to the customers (like when you buy software you get an .exe quite often which is really hard to reverse engineer and you will never get the exact source code out of it).

  11. How come when I go to display the data all I get are blank strings? I don't get an sql errors and it's working well enough to know that theres only 2 topics in my news forum (eg it only draws 2 boxes rather than the max of 5)

     

    I just really don't see what Ive done wrong :(

    $result = mysql_query 
    ("
    SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_first_post_id, t.topic_time, p.post_text, p.topic_id
    FROM phpbb_topics AS t, phpbb_posts AS p
    WHERE t.forum_id='$newsID' AND t.topic_first_post_id=p.topic_id
    ORDER BY t.topic_time
    ") or exit (mysql_error());
    
    $i = 0;
    while ($data = (mysql_fetch_array($result) or exit (mysql_error())) && $i < 5)
    {
    $date  = $data['topic_time'];
    $title = $data['topic_title'];
    $id    = $data['topic_id'];
    $post  = $data['post_text'];
    $i++;
    echo
      '<div class="body_news">' .
      '<a href="http://syncproductions.exofire.net/viewtopic.php?f=' . $newsID . '&t=' . $id . '"/>' . 
      $title . '</a><br />' .
      'Posted on: ' . $date . '<br />' .
      '<hr />' .
      $post .
      '</div>';
    }
    

     

  12. - you should probably hash the password, even salt it.

    - not sure but are you passing / storing the password everytime, if so, just check password once and then use a session id of some sort

    - not that it's srictly relevant to this q, but you want some kind of error checking on your sql comm's

     

    1) K done that now.

     

    2) If I presume the $_SESSION has the correct ID/username/password can't people fake the session and pick any id they please?

     

    3) Done.

  13. Not sure how I'm meant to do absolute here. I don't know how "high" the body block will be because it is a php page and gets that from a data base and if I don't do abosulote with the footer as well it seems to put the footer "ontop" of everything else:(

     

    anyway heres there entire page source.

    All the formatting is done by CSS and the includes don't contain anything that should effect the positioning (eg main_nav.php only uses the "span.nav_..." stuff)

     

    <?php
    include ('./globals.php');
    $page_name = 'Index';
    $page_type = 1;
    include ('./main_header.php');//includes <html>, <head> and <body>
    //connects to data base ($con);
    ?>
    <div id="nav">
    <?php include ("./main_nav.php");?>
    </div>
    
    <div id="body">
    <?php
    $result = mysql_query("SELECT Text_1 FROM data WHERE ID=1");
    if (!$result)
    {
    	exit (mysql_error());
    }
    $data = mysql_fetch_array($result);
    echo $data['Text_1'];
    ?>
    </div>
    
    <div id="footer">
    <?php include ('./main_footer.php');?>
    </div>
    
    </body>
    </html>
    

     

    and the CSS

    body
    {
    background-color: #0000CC;
    padding: 0
    }
    
    /*-------------------------*/
    /*===========NAV===========*/
    /*-------------------------*/
    div#nav
    {
    float: left;
    background-color: #000033;
    border-style: solid;
    border-color: #009999;
    border-width: 1px;
    color: #CCCCCC;
    text-align: center;
    width: 150px;
    }
    
    span.nav_header
    {
    text-decoration: underline;
    font-weight: bold;
    font-size: large
    }
    
    span.nav_home
    {
    font-weight: bold;
    }
    
    span.nav_result
    {
    
    }
    
    /*--------------------------*/
    /*===========BODY===========*/
    /*--------------------------*/
    div#body
    {
    background-color: #000000;
    border-style: solid;
    border-color: #009999;
    border-width: 1px;
    color: #CCCCCC;
    text-align: center;
    position: relative;
    left: 160px;
    right: 170px;
    }
    
    /*----------------------------*/
    /*===========HEADER===========*/
    /*----------------------------*/
    h1.header_title
    {
    text-align: center;
    text-decoration: underline;
    font-weight: bold
    }
    
    /*----------------------------*/
    /*===========FOOTER===========*/
    /*----------------------------*/
    div#footer
    {
    background-color: #000000;
    border-style: solid;
    border-color: #0011AA;
    border-width: 1px;
    color: #EEEEEE;
    text-align: center;
    width: 400px;
    }
    

  14. Why is the "right:170px" ignored on the div#body?

     

    Style sheet contents

    div#body
    {
    background-color: #000000;
    border-style: solid;
    border-color: #009999;
    border-width: 1px;
    color: #CCCCCC;
    text-align: center;
    position: relative;
    left: 160px;
    right: 170px;
    }
    
    div#nav
    {
    float: left;
    background-color: #000033;
    border-style: solid;
    border-color: #009999;
    border-width: 2px;
    color: #DDDDDD;
    text-align: center;
    width: 150px;
    }
    

    html page

    <!--bunch of header stuff-->
    <div id="nav">
      <!--Verticle nav bar-->
    </div>
    
    <div id="body">
      <!--lots of text-->
    </div>
    
    <!--footer-->
    

  15. How secure is this? Is it easy for someone to hack and if so what can I do to make it more secure?

     

    <?php
    session_start();
    $message = '';
    include('./globals.php');
    $con = mysql_connect($data_host,$data_user,$data_pass);
    mysql_select_db($data_base, $con);
    
    if (isset($_POST['logout']))
    {
    	unset($_SESSION['ID']);
    	session_destroy();
    }
    
    if(isset($_SESSION['ID']))
    {
    	$user_id   = $_SESSION['ID'];
    	$user_name = $_SESSION['Name'];
    	$user_pass = $_SESSION['Pass'];
    	$result = mysql_query("SELECT Name, Password FROM admins WHERE ID='$user_id'");
    	$data = mysql_fetch_array($result);
    
    	if ($user_name != $data['Name'] || $user_pass != $data['Password'])
    	{
    		session_destroy();
    		exit('Invalid Session:');
    	}
    }
    else
    {
    	$user_name = $_POST['user_name'];
    	$user_pass = $_POST['user_pass'];
    	$result = mysql_query("SELECT Password, ID FROM admins WHERE Name='$user_name'");
    	$data = mysql_fetch_array($result);
    
    	if ($data['Password'] == $user_pass)
    	{
    		$_SESSION['ID']   = $data['ID'];
    		$_SESSION['Name'] = $user_name;
    		$_SESSION['Pass'] = $user_pass;
    	}
    	else
    	{
    		$message .= 'Password and username do not match data base!';
    		session_destroy();
    	}
    }
    ?>
    

    Then some other stuff on the page...

    if(isset($_SESSION['ID']))
    {
    	//Log out
    	echo
    		'<div>You are logged in as ' . $user_name . '</div>' .
    		'<form action="./admin.php" method="post">' .
    		'<input type="hidden" name="logout" value="1">' .
    		'<input type="submit" value="Log Out">' .
    		'</form>';
    

    Bunch of admin stuff

    else
    {
    	echo
    		'<div>To access this page you must be logged in!</div>' .
    		'<form action="admin.php" method="post">' .
    		' UserName: <input type="text" name="user_name"><br>' .
    		' Password: <input type="password" name="user_pass"><br>' .
    		' <input type="submit" value="Submit">' .
    		'</form>';
    }
    

  16. How can I build a form (useing a sql query like the one below) that the user can use to update an entire table in one go (eg like the table at the bottom)?

     

    $result = mysql_query("SELECT * FROM sections ORDER BY Display_ID DESC");
    while ($data = mysql_fetch_array($result))
    {
        the form. This can post the data to another page which actauly makes the change
    }
    

    The table "sections"

    ID int NOT NULL AUTO_INCREMENT,
    DisplayID int,
    Name varchar(64),
    Description text,
    PRIMARY KEY(ID)
    

     

    PHP: 5.2.5

    mysql: 5.0.27

    Host: http://x10hosting.com

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