mikulucky 25 Junior Poster in Training

I agree this is going to cause serious problems allowing users to be any level they wish!!!! The site will not last more than a week online with that security!!!

mikulucky 25 Junior Poster in Training

@simplypixie be me to it :D

mikulucky 25 Junior Poster in Training

Ok that is great to hear, could you please mark the thread as solved, and give rep to the people whom helped. Glad we could help :)

Thanks

mikulucky 25 Junior Poster in Training

Ok the port section check if there is a port variable, so for example.com:80 or something, but checks that if there is a port, then it must be a valid number. The user and password is if your using apache auth through the URL, this just checks that the username and password are in the correct format. While the HOST IP checks that if the hostname is of a valid type or if just an IP is given this follows IP convention.

mikulucky 25 Junior Poster in Training

I would keep all the of the reg in there, I lifted this from my applications, I keep this as a common function, and I find it is good practise, as you might want to support other url's later on.

The reason it is on sperate lines is because its much easier to read, it could all be on one line, all it is doing adding them together to make one large expression. Each line is split into separate sections of the expression.

Also I find you can't overkill validation. But that is my opinion.

Hope this helps :)

mikulucky 25 Junior Poster in Training

Hi

Yeah this can be really horrible at times!!!!

This is a snippet, I would recommend changing this into a function of some sort, just returning true or false.

$regex = "((https?|ftp)\:\/\/)?"; // SCHEME 
    $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass 
    $regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // Host or IP 
    $regex .= "(\:[0-9]{2,5})?"; // Port 
    $regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path 
    $regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query 
    $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor 

    
    $url = 'http://www.domain.dk/seo/friendly/url';
    
       if(preg_match("/^$regex$/", $url)) 
       { 
               print 'true'; 
       }
klemme commented: Provided a great snippet for validating URLS! +3
mikulucky 25 Junior Poster in Training

sorry if i am disgusting you plzz dn't mind and help me.

Don't worry we can't all know everything, although it would be nice :)

Here is it briefly:

Well if the user has logged in then they are active? At the time of activating the member login, update the table in the database. Then when they log out they are not active so update the database table to reflect this.

What is it you do not specifically understand? And we can do each step at a time.

mikulucky 25 Junior Poster in Training

If they have to login, then you can store that user in a session. If you want an overview of all the people online, you may want to store that in the database.

What pritaeas means is when you user logs in, then there would be an extra column in your table for your users called for example active. When the user logs in then your log in script will update this field to 1, then when the user logs out it could change it to a 0.

Even better would to be to have another column as well as the above which has an expire time, so when the user logs in it is set to active, and the expire time is set to the same as the death of the cookie. This means that you can have another script that checks this table updating all the statuses of the users who are marked as active however the expire time has passed.

Well that is a bit more detail, but all credit goes to @pritaeas for solution.

pritaeas commented: Thanks for explaining ;) +14
mikulucky 25 Junior Poster in Training

Yeah I realise that yOur a student. But you don't seem to grasp the basics. And you should not need help at every step. You should solve problems yourself, the major part of being a programmer is to problem solve. Not to ask for help as soon as your stuck.

mikulucky 25 Junior Poster in Training

begining you test $_POST and if it is accept do what you need for accept and vice versa

This would be the best way to do it.

mikulucky 25 Junior Poster in Training

Ok first, have you made sure that there is a session_start(); at the top of the script?

If this is the whole script, where is this query your doing, there might be something wrong with that?

On this IF Statement your missing a bracket at the end. It should be:

if ($_SESSION['SESS_rank']==employee.rank("admin"))

Also what is this??? employee.rank("admin") Also you have extra brackets in your IF/ELSE blocks so this will mess things up. Also I think you need to read the manual on IF control statements, as you have one conditional and all the rest are ELSE, which means that only the first ELSE will ever get triggered. Here is the manual for it PHP.net Surprise!

The next problem is that the code formatting is a mess, I hope your IDE is creating this, if so, then get a new IDE.


Finally.......

I hate to sound negative, but this seems to be on a similar theme

You seem to be programming way above your ability, hence the simple mistakes of control statements. Along with the fact that you only past your problem, saying solve this or debug it for me. You hardly ever seem to provide errors, and all the code snippets you do provide seem to be to make a whole application. I hope your not charging someone for this application.

mikulucky 25 Junior Poster in Training

Have a column in the employee table which say the type of employee they are, for example, doctor, nurse, domestic and so on.

Then when they log in see what type they are and do a switch statement for each on with a header redirect to the page that you want them to go to.

mikulucky 25 Junior Poster in Training

From scratch? You must be familiar with this then.

That's great :D

mikulucky 25 Junior Poster in Training

All you would have to do is like your doing already, if you have a value that states the users type, then if not admin then echo something with a link. Or if the user account as you are only searching for admin users, then if the user is not found based on the credentials that have been passed to you then have a common redirect. Stating that your login failed, please try again.

mikulucky 25 Junior Poster in Training

Ok the code needs to be tidied up. Instead of using loads of "echo statements", mixed with variables use printf like below. Only use echo for constant strings that you don't want to change. However you should not really mix php with html, or other sorts of design, as it can get really messy and easily break a page.

$result = mysql_query ("SELECT * FROM cal WHERE data = '(2012-01-01)' " ) ;
$events = mysql_num_rows($result) ;

if ( $events )
{
   echo "<td class = 'date_has_event'> <div class='events'> <ul> " ;
   	
   while ( $row = mysql_fetch_array ( $result ) )
   {
      printf("<li><span class='title'>%s</span><span class='desc'>%s</span></li>",$row['title'],$row ['event'] ) ;		   				   
   }
	   
    echo " </ul> </div>  </td>";
	
} else {
	
    echo "<td></td>";

}

As for your second question no your not able to do this, however if there was a way to do this, I would not recommend it, as it looks like it could get really messy. You want your code to be as clear as possible incase you need to go back to it in years to come.

Well I hope that this helps. :)

mikulucky 25 Junior Poster in Training

Well what do you want to achieve?

mikulucky 25 Junior Poster in Training

<td> tags are for tables not for the selection of radio buttons. to group radio buttons together, the names of all the radio buttons should be the same, like in the example I have shown you above.

mikulucky 25 Junior Poster in Training

I don't understand the %s bit, when executed there is nothing %s, could you explain?

The '%s' means that this is a placeholder for a string, which is later filled in with the value stated later. So the first '%s' would be filled in with '$row' while the second with '$row'.

The line of code that I gave you has to be placed within the WHILE loop. So:

if (isset($_POST['search_now'])) 
{
    $result = mysql_query("SELECT * FROM bands WHERE BandName LIKE '%$BandName%'");  


    while($row = mysql_fetch_array($result)) 
    { 
        $page = sprintf( "<a href='http://www.website.com/%s'>%s</a>" , $row['PageName']  , $row['BandName']  ) ;
        echo 'Band Name:  '; 
        echo $row['BandName'] ." " . $row['Genre']; 
        echo $page;  
        echo "<br />";
    }
}

This is because you wish to create a link, however in your first example, you was trying to populate the link with data that you did not have yet, as it was before the query to the database was run.

One more thing I would tidy the code up a bit more, having each command on a new line. Well I hope that this helps :)

mikulucky 25 Junior Poster in Training

First of all change this from:

$page = "<a href=\"http://www.website.com/$row['PageName']\">$row['BandName']</a>";

To:

$page = sprintf( "<a href='http://www.website.com/%s'>%s</a>" , $row['PageName']  , $row['BandName']  ) ;
mikulucky 25 Junior Poster in Training

Have you specified that they are in a group, they only allow for single selection if they are part of a group.

For example

<input type="radio" name="group1" value="PersonA">
<input type="radio" name="group1" value="PersonB">
<input type="radio" name="group1" value="PersonC">
mikulucky 25 Junior Poster in Training

Well if you go with the noah idea, that the 1 ark was able to 2 two of every animal on the planet. We would only need one to fit all of humanity. As there is current around 8.7 million species of animals. Multiply that by two, thats 19.4 million animals. However to allow for the size differences such as insects and so on, I would say a save bet would be 3 arks, for the humans. All other animals DNA and plant matter is secure in vaults which can be retrieved later, no point building more arks for them.

However this is just an estimate :D

mikulucky 25 Junior Poster in Training

Hope this helps, can be turned into a function easily.

$startAmount = 0;
$endAmount = 100000;

for ($i = $startAmount; $i <= $endAmount; $i++) 
{
    if($i % 2 != 1) 
    {
      continue;
    }
 
    $d = 3; 
    $x = sqrt($i); 

    while ($i % $d != 0 && $d < $x) 
    {
        $d += 2; 
    }

    if((($i % $d == 0 && $i != $d) * 1) == 0) 
    {
        echo $i.' '; 
    }
 }
cereal commented: great solution +7
mikulucky 25 Junior Poster in Training

I have looked through your other posts, they all have the same theme. Your a student, doing an MSc, who posts their assignments online, or parts of them. Then gets members to answer them for you. If your doing an MSc surely you must have learnt in your BSc or number of years of experience in order to qualify to attend an MSc that RTM (Read The Manual).

Just google PHP and go to the PHP website. Sorry for the other members who have attempted to help him, But read through his other posts, some of them are unbelievable.

mikulucky 25 Junior Poster in Training

In php, I can do more design of my website.

I also think PHP would be the best option, It is easy to learn, and allows fast development. It does not have downtime when deploying, I have a dev server and live server, so its just a matter of svn. However the draw back of PHP is that it can get really messy really easily. If speed is your main goal, then I would go for servlets and JSP.

As for using PHP for design on your website, I might have read your post wrong. But you should really sperate the logic from the design. PHP should be at least a 3 tier system, Database -> PHP -> Template, because as I said PHP gets messy, mix php with content and HTML, well its like alphabet soup.

peter_budo commented: Little contradiction there, but finally someone posting more then "me too love PHP" +0
warlord902 commented: Nice reply +0