Hi folks,
In my script I have this code: -
<?php
-
-
unset($errors);
-
-
include ("linesfile.php5");
-
$filename = "data.line";
-
set_magic_quotes_runtime(0);
-
-
if ($_POST['submit'] && strlen($_POST['input']) < 5) {
-
$errors[] .= _NO_5;
-
}
-
if ($_POST['submit'] && strlen($_POST['username']) < 3) {
-
$errors[] .= _NO_2;
-
}
-
$dirty = array('rude word', 'another rude word', 'etc');
-
-
foreach($dirty AS $bad_word){
-
if(preg_match("/$bad_word/i", $_POST['input'])) $errors[]= 'The word you entered, "'.$bad_word.'", has been detected as being offensive; your post has not been submitted. Sorry for any inconvenience.';
-
}
-
-
-
-
-
?>
-
<div class="ddgb_entrybox">
-
<table width="100%" border="0" cellspacing="8" cellpadding="0">
-
<tr>
-
<td width="42%" align="center" valign="top"></td>
-
<td align="left" valign="top">
-
<?php
-
-
if (isset($_POST['submit']) && $errors[0] != null) {
-
echo "<h2>" . _ERROR . "</h2><ul>";
-
foreach ($errors as $f) {
-
echo "<li>" . $f . "</li>";
-
}
-
echo "</ul>";
-
} elseif ($_POST['submit']) {
-
// grab the inputted text
-
$text = htmlspecialchars(stripcslashes($_POST['input'] . "\n"));
-
$username = htmlspecialchars(stripslashes($_POST['username']));
-
$color = $_POST['color'];
-
$font = $_POST['font'];
-
$ip = $_SERVER['REMOTE_ADDR'] . "\n";
-
$ip1 = $_SERVER['REMOTE_ADDR'];
-
$time = time();
-
$_SESSION['username'] = $username;
-
$_SESSION['color'] = $color;
-
-
-
$data[] = "\n" . htmlspecialchars_decode(substr($username, 0, 10));
-
$data[] = trim($color);
-
$data[] = trim($font);
-
$data[] = htmlspecialchars_decode(trim(substr($text, 0, 75)));
-
-
-
-
-
//Process the post
-
-
$datafile = new DataFile($filename);
-
if (!$datafile->writeNewLine($data))
-
die("Error writing to file");
-
-
}
-
-
?>
-
I have a database set up called `chatbox` with a table `post` having the fields 'time' and 'ip'.
The idea: when the user posts, their ip is stored in the database along with the time stamp from when they post using
[php]$sql = "INSERT INTO `chatbox`.`post ` (`time`, `ip`) VALUES ('$time, $ip)"; //$time being merely time() and $ip being $_SERVER['REMOTE_ADDR'];
$result = mysql_query($sq l) or die('Error in SQL: ".mysql_error() );
[/php]
I was planning to then query the database to see whether that ip (user) posted within the last 30 seconds ( if($row['time'] < ($time + 30)) { } ) if they have then $errors[] = 'You have already posted once, please wait 30 seconds to post again'; if not then it will post the form.
I have the code to use but how would I impliment this into my code?
Thanks,
Sam
1 1734
I've managed to come up with a solution.
Sam
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jay Moore |
last post by:
Greetings, all!
I have a project for work, and I'm not sure how to efficiently do what I
need to do. I'm hoping someone out there can help.
Project is this: I'm creating a web-based interface where people at my
company (operators) can enter data for service calls. All data entered
is run thru one or more PHP scripts for error checking and then stored
in a MySQL database on a server here in the office.
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: Erik H. |
last post by:
Trying to connect to MySQL db on localhost, and populate datagrid from a
dataset using code inline method.
Getting the following compile error:
Error Message: "CS0246: The type or namespace name 'CoreLab' could not be
found (are you missing a using directive or an assembly reference?)"
I downloaded the add on for connecting to MySQL using ADO.NET and installed
it, but am still getting this error. Anybody ever run into this before?
|
by: SC |
last post by:
I'm developing a site that may eventually have a very large database of
users (hopefully, but who knows). It will be a community website where
users can search each other (think Friendster, Classmates, every dating site
out there, etc.).
Often there will be queries with multiple joins and sometimes may include a
few fulltext searches. Each page of results will have a limited number of
results displayed (obviously). As I understand it,...
|
by: mattdfong |
last post by:
I am using mysql to receive stock market rate data, and I have a rate
feed which tells me when the rate has changed. I input the data as it
comes in, into a mysql database that has both a unix_timestamp() field
and the rate field. Neither field is indexed.
What I need to do is calculate the Moving Average by taking the rate
from 30 seconds, 60, 90, etc seconds ago. Currently I am using the
humungous sub query select statement below. Are...
| |
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
by: Chrom_ |
last post by:
Mysql is filling my /var partition because the log limit doesn't seem
to be respected.
I've tried many different settings in /etc/mysql/my.cnf but nothing
works.
Logrotate is not enabled/configured. I just want mysql to use a maximum
of, let's say, 1GB of my /var partition
The log is /var/log/mysql/
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get through this without much trouble. Programming knowledge is not required.
Index
What is SQL?
Why MySQL?
Installing MySQL.
Using the MySQL command line interface
|
by: chanshaw |
last post by:
Alright so I got php running and installed i have mysql running and installed the thing im having a hard time with is having the php to call information from the mysql database. Im on Windows Vista Ultimate, I'm using iis7 here is the code of the php.
<?php
$Username = "Webuser";
$Password = "password";
$Database = "sample";
$Hostname = "localhost";
$MySQLConnection = mysql_connect($Hostname, $Username, $Password) ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |