Will Gresham 81 Master Poster

Ok, my final response, you are clearly going to continue to be ignorant.

Taken from php.net (The people who manage PHP, they have much more knowledge of PHP than you)

How can I pass a variable from Javascript to PHP?

Since Javascript is (usually) a client-side technology, and PHP is (usually) a server-side technology, and since HTTP is a "stateless" protocol, the two languages cannot directly share variables.

Link to PHP.net article

Will Gresham 81 Master Poster

I am not saying that I am the first one who figure it out....

No, you have yet to figure it out, you seem to be deliberately missing the point being made here

I hope you understand the topic.....is it very clear....that it works!
that when you trigger the onchange...it will run the php function...

No, the text in the PHP function is being parsed on the server, it has nothing to do with Javascript or onChange

even with or without code on view source....the output came from php function bro. if you want source code...RETURN THE WHOLE PAGE WITH HEADER....using heredoc.

Again, you have yet to figure it out.

Or is this your idea of a bad joke?

Will Gresham 81 Master Poster

Ok, in the other thread you started, you posted this example:

<?php
function myfunction(){
mysql_query('INSERT INTO `table` SET `column`="value"') or die(mysql_error());
return 0;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
function ILovePHP() {
b = "<?=myfunction();?>";
alert(b);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post"><input name="" name="" type="text" onChange="ILovePHP();"></form><p>
</body>
</html>

Now, load a page with that script in, then check your database BEFORE you click the textbox or do anything, I can guarantee you that the new entry will be in the database, meaning that it has been executed BEFORE you trigger the onChange event, meaning that the onChange WILL NOT update the database, it has already been done when the script loads.

You have been told the same in 2 threads on Daniweb, and you say that you found the same answer on other sites. This should indicate that Javascript cannot interact with PHP in the way you are claiming it does.

Will Gresham 81 Master Poster

Yes, this will work for static pages, but the PHP is being processed server side BEFORE it is sent to the browser, look at the source code in your browser, no PHP there.

PHP = Server Side
Javascript = Client Side

You can use pre-defined PHP variables in Javascript, but you cannot /do/ anything with PHP after the script has been processed and sent to the client.

Will Gresham 81 Master Poster

More info is needed for an accurate response, speaking generically, you need a database, which will store a username, user ID and a password at minimum (A user ID isn't actually essential, but indexing a text field takes more time than indexing an integer field)

Further than that, depends entirely on what the site is for, and until you have a database structure drawn up, I wouldn't even bother thinking about a management script.

You have asked a very vague question, the best apporach would be to search the internet: link 1 link 2, then get a script going and ask specific questions if you encounter problems.

Will Gresham 81 Master Poster

Looking at your code, I think you have your variables in a mix:

echo '<a href="' . $row['thumb']. '"><img src="' . $row['url']. '" /></a>';

Would output (for row 1)

<a href="001.jpg"><img src="001.php" /></a>

Swap over the variables so that the thumb is in the img tag and the url is in the a tag.

Borderline commented: Many thanks. +1
Will Gresham 81 Master Poster

The code you put would be exactly the same as typing

<script language="javascript" type="text/javascript">
function ILovePHP() {
b = "I love PHP ! by Arman de Guzman de Castro :-)";
alert(b);
}
</script>

As ShawnCplus said, PHP is not being run in the onChange event.

To 'run' PHP code in the onChange event, look into ajax to send requests to your PHP script and get the results without the requirement of a page reload.

Will Gresham 81 Master Poster

What is the actual error you are getting?

Will Gresham 81 Master Poster

Are you using 'bbcode' or something similar to allow the users to add their messages? This would be one of the simplest ways to do it.

My example here uses 'bbcode', the PHP for quotes is this:

<?php
   function bbcode($Text)
       {
            // Check for Quotes
            $numquotes=substr_count($Text, "[quote=");
            for ($i = 0; ($i < $numquotes); $i++)
            {
            $Text = preg_replace("/\[quote\=(.+?)](.+?)\[\/quote\]/s",'<span class="quotebody">$1 Said:<br />$2</span>',$Text);
            }
      }
?>

This is not the whole bbcode script, just the bit that checks for [quote=name] tags
CSS:

.quotebody {
   background-color: #ffffaa;
   font-family: Verdana, Tahoma;
   font-size: 1em;
   color: #660002;
   border: 1px solid #000000;
   margin-left: 5px;
   display: block;
}

And the part of the script that calls the bbcode function:

<?
        echo "<td width=\"80%\" class=\"singlepost\" valign=\"top\">
                ".bbcode(htmlspecialchars($req_post['text']))."</td>";
?>

Again, not a complete script, just a snippet.

Using the above, a user who enters this:

This is a test
[quote=test]
test
[quote=test]
test
[quote=test]
test
[quote=test]
test
[/quote]
[/quote]
[/quote]
[/quote]

Would get something similar to what is shown in the attached image

Hopefully this will give you some idea of what to do.

Will Gresham 81 Master Poster

I felt like a change:
MCR - Our Lady of Sorrows

Will Gresham 81 Master Poster

This may not be the best way to do it, but it should work

$thisYear = date('Y');
$nextYear = $thisYear + 1
$nowdate = $thisYear "-" $nextYear;

I really need to go to sleep :D

Will Gresham 81 Master Poster

Iggy Pop - Real Wild Child :cool:

Will Gresham 81 Master Poster

Are you asking how to check for only numbers in a string? if so is_numeric would do this:

if (is_numeric($password)) {
        echo "Password is numeric";
     } else {
        echo "Password is not numeric";
   }

Or for alpha-numeric strings:

if (preg_match('/^[A-Za-z0-9]+$/', $password)) {
  // Do something
}
Will Gresham 81 Master Poster

Number 5 had me laughing for a minute there :D

Will Gresham 81 Master Poster

PHP would not be the best way to do this, not only due to the fact that page load times need to be taken into consideration (as already mentioned) but also because alot of the typing speed tests also take into account accuracy of the words typed. The code by cwarn23 above will count how many characters/words have been typed into a textbox and how long it took (roughly) but this would not stop you typing gibberish or 'a a a a a a a '....etc into the box.

You would really need something client-side (JavaScript maybe if it must be a web app) and a preset paragraph(s) to be typed. The script would then need to analyze the text as it is typed to make sure the words are input correctly, and if they are not then to make this count against the user. While this could be done in PHP, it is not going to be the simplest or easiest solution.

This is not a matter of 'basic code'.

Will Gresham 81 Master Poster

Actually the math is 8^62 8 positions with 62 possibilities in each, special characters excluded 62 positions where each will only be 1 of 8 options yields significantly less possibilities.

Not to nitpick your math, because ultimately, our points were the same as the one you made, it would take to long to generate them all.

Whoops, should have checked that, I always get them mixed up :( knew I should have paid more attention in Math :D

So add alot more zero before the decimal point in my last post and you'll have a closer figure (as if the numbers I 'worked out' weren't big enough)

Will Gresham 81 Master Poster

On the basis of an 8 character password, where each letter can be 1 of 62 possibilities (a-zA-Z0-9) that is 9.807971461541689e+55 possibilities.

Or 62^8, or 218,340,105,584,896 possibilities...

i was able to get 650 attempts per second with my laptop alone and I have 5 exactly the same

Ok, 5 of them, assuming you figure a way to start at a certain position and not just do the exact same on all 5 would be 3,250/second.
or 3,639,001,759,748.26 Seconds,
or 60,650,029,329.13 Minutes,
or 1,010,833,822.15 Hours
or 50,541,691.10 Days
or 138,470.38 Years
(please correct me if my math is wrong, its the end of a long day :))

Either way, it will take a long time with a PC (or PCs) like yours.

Oh, and in response to your actual question:

Is there any way to get my PHP app to generate passwords in sequence

Yes.

Will Gresham 81 Master Poster

:) It'll be a long time before this happens, they'll find some story the credit crunch to further depress people if nothing else :(

Good find (even if it is fake :D)

Will Gresham 81 Master Poster

Thanks for the ideas :)

Upper case tags are a no, I work in XHTML1.0 Strict :D
The suggestions posted are alot longer than my original, but if they are better in terms of standards then its all good.
I'll let you know how it goes :)

Will Gresham 81 Master Poster

Another good band.
Actually listening to them right now on Slacker Radio - "Almost Easy".

Some of their songs (and videos) are a bit odd though, 'A Little Peace of Heaven' comes to mind ... http://www.youtube.com/watch?v=hPp1VQuBYFM

Best song by them has to be 'Unbound [The Wild Ride]' http://www.last.fm/music/Avenged+Sevenfold/+videos/+1-AD4TG-smyUk

Will Gresham 81 Master Poster

Thanks for the link. I did search google but I couldn't find anything, probably just searching the wrong way :(

So do you know of a better way to do this? I did think about using toLowerCase() but this would remove all capital letters from the text as well... For the moment I am using a replace on all <br> <BR> <br /> and <BR /> to convert them to newline characters, but eventually some HTML tags other than br will be added to the text so this is only a temporary fix...

Thanks again :)

Will Gresham 81 Master Poster

Very informative :)

I will remember this one for future reference. Rep+ for you all :)

Will Gresham 81 Master Poster

Ideas/Suggestions:
1. Read up on XML
2. Read up on PHP (especially Multidimensional and associative Arrays - they will help no end on this sort of project)
3. Look at other peoples (open source) work for ideas
4. Design
5. Find flaws in design
6. Start coding
7. Ask Daniweb for assistance if something doesn't work (and provide relevant code snippets)

Hope that's enough to get you going.

Will Gresham 81 Master Poster

Avenged Sevenfold :)

Will Gresham 81 Master Poster

Wasn't sure what to put as the title, but what is happening is this:
I have div elements on a HTML page, when they click on the div it is replaced with a textarea containing the div contents in order to edit this (eventually there will be a form/submission button there, but I need to sort this first) but the problem is that in IE it is printing all tags in uppercase, is there a problem with my code or is just just another problem in IE? (I am using IE6, I have not tested in 7 or 8)

Code:
HTML:

<h2><br>Signing Course.</h2>
<div id="event_1" onclick="edit_content(this.id)">Barrie Paddon is soon to start a group for those wishing to learn basic sign language.<br>
Barrie who has achieved level 2 in British Sign Language led a large
group last year who spectacularly sang The Lord’s Prayer in sign
language. All interested please contact the office.<br></div>

JS:

<script type="text/javascript">
function edit_content(container) {
if(document.getElementById(container).innerHTML.substr(0,5) == "<text") {
} else {
document.getElementById(container).innerHTML = "<textarea name=\"" + container + "\" rows=\"10\" cols=\"90\">" + document.getElementById(container).innerHTML + "</textarea>";
editing = '1';
}
alert(document.getElementById(container).innerHTML.substr(0,5));
}
</script>

IE outputs:

Barrie Paddon is soon to start a group for those wishing to learn basic sign language.<BR>Barrie who has achieved level 2 in British Sign Language led a large group last year who spectacularly sang The Lord’s Prayer in sign language. All interested please contact the office.<BR>

into the textbox, and the alert shows '<TEXT'

Any …

Will Gresham 81 Master Poster

Have you tried echoing $addtolist to make sure that it contains the value expected?

theimben commented: Thanks for your help - !Unreal +2
Will Gresham 81 Master Poster

What error is returned?
Add or die(mysql_error()); to the closing bracket of the query as so:

mysql_query("....")or die(mysql_error());
Will Gresham 81 Master Poster

We cannot see your PHP code, so there is no possible way we can tell you what is wrong, please post up some code so that we can look at it.

Will Gresham 81 Master Poster

I believe

// if your email succesfully 
if($sentmail){
  echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
  echo "Cannot send Confirmation link to your e-mail address";
}

should come after

$sentmail=mail("$email",'Registration Conformation',"$message");

.

At the moment, you are using the mail() and then re-directing without checking if the send was successful.

Will Gresham 81 Master Poster

Also mate! not trying to get answers or want experts here to do my homework.......have no intensions like these..........

Good enough, just you had no apparent effort put into your first post, and said 'I am trying to create a forum system for my university website.'
My bad:)

Will Gresham 81 Master Poster

Alternating between Metallica and Queen

Will Gresham 81 Master Poster

The last part should be

$result = mysql_query("SELECT url FROM blacklist WHERE url = '$hostname'");
if (mysql_num_rows($result) != 0) {
  echo 'URL already in DB';
} else {
  for ($i = 0; $i < $hrefs->length; $i++) {
    $href = $hrefs->item($i);
    $url = $href->getAttribute('href');
    echo $url.'<br />';
    $query = "INSERT INTO spider (url, site) VALUES ('$url', '$hostname')";
    mysql_query($query) or die('Error, insert query failed');
    $query1 = "INSERT INTO blacklist (url) VALUES ('$url')";
    mysql_query($query1) or die('Error, Blacklisting failed');
  }
}
Will Gresham 81 Master Poster

For input:

<input type="text" name="username" value="<?php echo $_SESSION['username'] ?>">

Textarea:

<textarea name="somename"><?php echo $_SESSION['username']?></textarea>

You get the idea?

Also, once the user has been added to the db, use session_destroy() to remove the session, preventing problems when they login.

I would say store the user ID/username and the encrypted password in the session, validate the user at the start of all files.

Will Gresham 81 Master Poster

That and explode is supposed to execute faster due to the lack of regex, although for what the OP wants, I doubt it will make much difference which is used.

Will Gresham 81 Master Poster

!Unreal's suggestion is best, you haven't said what you want in index.php, you haven't said what the table structure is...

You aren't giving us anything to work with.

Once you have a file, post here asking questions if it doesn't work, but we aren't here to do your homework for you.

Will Gresham 81 Master Poster

Any chance you can post some more of the script, for example what $hrefs contains?

I dont think that will work, but if you post up some more it would be easier to provide a decent response/suggestion.

Will Gresham 81 Master Poster

Save the form values into a session:

if(!$_SESSION) {
session_start();
}
foreach($_POST as $key => $value) {
$_SESSION[$key] = $value;
}

Then on the form set the value to the session variable, a form element with the name 'username' would be in $_SESSION, 'password' would be in $_SESSION etc.

Will Gresham 81 Master Poster

No need to 'stop' the script, in the if statement just add some code to process if the name is already in the db, add an else onto it to insert a new record if the name does not exist.

If you really want, you can use the die() function, but this will also stop and further processing of any HTML, so you may end up with half a page if this script outputs anything to the user.

Try this:

$check_name = mysql_query("SELECT `username` FROM `users` WHERE `username` = '$requested_name'");
if (mysql_num_rows($check_name) != 0) {
  // Error, username taken
} else {
  // Username is free, insert query goes here.
}
Will Gresham 81 Master Poster

Make another column in the database for hostname (call it whatever you like) and store the result of $hostname[1] in there.

Then when a new URL is submitted, get the hostname, and see if it already exists in the database, for example:

preg_match ('@^(?:http://)?([^/]+)@i', $addtolist, $hostname);
$site = $hostname[1];
$result = mysql_query("SELECT `hostname` FROM `spider` WHERE `hostname` = '$site'");
if (mysql_num_rows($result) != 0) {
  // Hostname already in db
} else {
  // Not in the db
}
Will Gresham 81 Master Poster

Something along the lines of:

$check_name = mysql_query("SELECT `username` FROM `users` WHERE `username` = '$requested_name'");
if (mysql_num_rows($check_name) != 0) {
  // Error, username taken
}

Do not rely on Javascript for validation, build your code assuming your users have Javascript disabled, you can always add things like alerts later.

Will Gresham 81 Master Poster

From what I have seen of your posts, your database contains URLs

You could use regex to strip everything from the name so instead of http://www.something.com/somepage.somefile you have something.com, store this in another column in the table, and on submission, strip everything from the submitted URL as above and see if it is already in the db, if it is, throw an error.

Will Gresham 81 Master Poster

The first line you posted will run the query, so the if statement will always return false as the row is already deleted, change

$sql1 = mysql_query("DELETE FROM spider WHERE url='$addtolist'");

to

$sql1 = "DELETE FROM spider WHERE url='$addtolist'";
Will Gresham 81 Master Poster

Try

mysql_query("INSERT INTO `list` (`title`, `url`, `description`) VALUES ('$title', '$addtolist', '$description')");
mysql_query("DELETE FROM `spider` WHERE url='$addtolist'");
theimben commented: thanks +2
Will Gresham 81 Master Poster

The problem is that you have specified the height and width for the div, not the image, the div will auto expand to allow its contents no need to assign height/width in this case. Move the height and width into the img tag.

<div style="text-align: center;"><img style="height:32px; width:32px;" src="<?php echo $row_reclog['picture']; ?>" alt="" name="loginimg" border="0"></div>
Will Gresham 81 Master Poster

Announcements are in the forums for a reason.....

http://www.daniweb.com/forums/announcement6-20.html

Will Gresham 81 Master Poster

Served with a side of fried bread and beans that could be the tastiest (and possibly unhealthiest) breakfast ever:$

Probably not good on a daily basis, but all that grease should clear out your insides in a matter of hours :P

Will Gresham 81 Master Poster

The code posted by ShawnCplus would show the image and scale it down to 32x32.

Do you get the image path from the database? or are you storing the image itself in the database?

I am not sure exactly what you are asking, but I see no reason why the code from ShawnCplus won't work, post up your code onto the forum to see if anyone can spot the problem, and as said HTML issues can go to the HTML board (this will likely go there as it seems to be with displaying the image, not with retrieving the path)

Will Gresham 81 Master Poster

Your title tag should be within the head of the document ;)

Rather than re-inventing the wheel, you may want to look at [www.smarty.net]Smarty[/url], it does everything you are looking for, you can get an array of data and have it auto output as a table - if you understand HTML and php then the learning curve should not be very steep.

Of course, i'm not saying you can't build your own - just that there are free solutions which do exactly what you want readily available.

Also, this is probably just me, but I find all caps on code hideous and annoying, especially since XHTML 1 says it should be lower case (if you are using HTML 4 then this is irrelevant, but as I said, its probably just me :))

Will Gresham 81 Master Poster

Had another look, you should define $directory as a global in the functions, just as the $thmb and $columns variables are.
Also, use a relative directory, change $directory = "G:/xampp/xampp/htdocs/"; to $directory = "."; and see if you get the correct output.

Will Gresham 81 Master Poster

Post the lines around line 101, it may be one of the preceding lines causing this problem.