PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Below is the code I use for my PHP shoutbox. I can read basic PHP fine, I can read and code basic VBA.
Here's what I need help on. Reply to any you know how to work.
[b]1. If any word from a list is present in the message, do not send.[/b]
[b]2. If more than one URL exists within message, do not send.[/b]
Can I do this by creating a variable $msg and checking it with with a string of some sort and check the above?
[b]3. I'd like to submit the msg, without the page reloading.[/b]
Using something like this to reload the Div containing the shoutbox results (I use this for a real time clock I coded in JS). Very open to other ideas.
[syntax="javascript"]function realtimeclock() { insert code... }
function cycle()
{
if (document.all || document.getElementById)
setInterval("realtimeclock()",1000)
}
window.onload=cycle
I don't understand the while {} loop in my shoutbox results. Can someone explain the code?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
kevinoneill wrote:3. I'd like to submit the msg, without the page reloading.
JavaScript or AJAX if the submit hits a database.
kevinoneill wrote:4. I want to install PHP on my computer so I don't have to upload to my site and reload to test things. How can I go about doing this on my Apple.
$count = substr_count($message, 'href');
if ($count > 2)
die ();
Problem is... the die kills the rest of the php on the page, I also had to insert it in after the 'message' has been given the value $message, so the content is already shot to the database before it dies....
I need to know how to assign the text inside my text area named 'message' can be assigned as a variable before being sent to the db, and also preventing the info from being sent to the db with out killing all php on the page...
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Ok this works next problem!!
if($submit)
{
putenv('TZ=America/New_York');
$time=date("F j, Y, g:i a", time());
$count = substr_count($message, 'href');
if ($count < 2) {
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)".
"VALUES ('NULL','$name', '$message','$time')");
}
}
Maybe you can help me with my other big issue. When my user submits, then say wants to reload the page to see if someone else wrote anything, you get the pop-up box asking "do you want to submit this data again?". Is there a way around that? This stems from my question #3.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I would recommend using a splash page. Similar to the page on these forums that say that your post has been entered successfully, you know? That way when they get redirected to their posting (or some other page) it is not from a POST (hence getting rid of the repost notice).
Well I've made alot of progress (ok i lie someone made alot of progress for me) but I'm at a hault because i get the "can't write to db" error down in the code.