I would like to know how is it possible to block a list of given ips from a mysql database table of ips.
For example i have a registration form and if the user has a different ip than the one from the mysql dbs he should see the form else he should see a message on that page "You are not allowed to use VPN/Proxy ips on this website".
First how do i create the mysql table and column, what properties do i need to add, so i can import the ips from a csv file.
MYSQL
CREATE TABLE IF NOT EXISTS 'blocked_ips'.......
and don't know how exactly to continue. Tried adding a column in phpmyadmin with VARCHAR(15) and after tried importing the csv file of ips, but it doesn't work, it only imports 2 rows and has only 00 containing in the 2 rows
<?php
//check for user ip
$ip = $_SERVER['REMOTE_ADDR'];
compare the ip got from the user with the mysql table column with ips
if the $ip matches with one from the table echo a message on the same page, (no pop-up).
else {
will echo the form below
?>
<DOCTYPE html!>
<head>
<title> Registration</title>
meta
meta
</head>
<body>
<table class="colortext" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%"> </td>
<td height="20" width="70%">{advertiser_msg:8921}</td>
</tr>
<tr>
<td>{advertiser_msg:1092} <span class="mandatory">*</span></td>
<td>{USERFIELD}<span id="fg" style="display: none;white-space: nowrap;"></td>
</tr>
</form>
</body>
</html>
I am a noob in this please help.
mysql_select_db("your database name") or die(mysql_error());
# Full Text Attempt
$query = mysql_query("SELECT `IP` FROM `your table` WHERE `IP` = '$ip'");
or
$query = mysql_query("SELECT `IP` FROM `database` WHERE `IP` LIKE '%$ip%'");
//chk for banned ip ipaddress
if (mysql_num_rows($query) > 0)
{
echo "<p> You are not allowed to register with proxy VPN </p>";
}
?>
Related
I have a very unique situation that I am going to explain as best I can!
I want to output users in a style like so:
Username:Password
Username2:Password2
etc etc...
But I cannot place text in a paragraph like <p>Username:Password</p>
I can only do it like so... <p>Username:</p><p>Password</p>
And as I can only have seperate tags on the username and password the design ents up looking like so:
Username:
Password
I also cannot use any CSS whatsoever.
But I am able to use any type of HTML tags I like! (Span tags of course wouldn't work as they would both be separate still)
Is there any possible way to do this with the rules I have given you, I have tried everything!
(I know it sounds strange what I am wanting to do but I have a strange parser software that can only do this)
Here is a snippet of the code to show you how this works:
$ids = Array();
$usernames = Array();
$passwords = Array();
while ($row = $getaccounts->fetch_assoc()) {
$ids[] = $row["id"];
$usernames[] = "<span>".$row["username"].":</span>";
$passwords[] = "<span>".$row["password"]."</span><br />";
}
$activezero = implode(",",$ids);
$username = "".implode("",$usernames)."";
$password = "".implode("",$passwords)."";
echo $activezero;
I know this looks absolutely stupid, but trust me, this is the only way of getting my program to parse everything properly.
How can I make it output what I want using the code that I have?
There are some Options to solve this without using CSS, you could either use a table or a definition list, for example.
<table>
<thead>
<tr>
<th>Username</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice:</td>
<td>abc123</td>
</tr>
<tr>
<td>Bob:</td>
<td>pa$$word</td>
</tr>
</tbody>
</table>
<dl>
<dt>Alice:</dt>
<dd>abc123</dd>
<dt>Bob:</dt>
<dd>pa$$word</dd>
</dl>
Maybe sth like it?
<span>Username:</span><span>Password</span><br />
<span>Username2:</span><span>Password2</span>
Username:Password
Username2:Password2
jsfiddle
I have a database table and I want to print the name. It isn't displayed correct, it's like this:
Abu Noooooora dddd#hotmail.com
���� ������� dddd#hotmail.com
almojaded dddd#islamway.net
WeldLibya dddd#hotmail.com
What can I do to print like:
Abu Noooooora dddd#hotmail.com
يوسف على dddd#hotmail.com
almojaded dddd#islamway.net
WeldLibya dddd#hotmail.com
My php code is:
<?
$dd = mysql_query("SELECT sname,semail FROM senders LIMIT 5");
while($ro = mysql_fetch_array($dd))
{
?>
<tr>
<td style="text-align:right;"><?php echo $ro["sname"]; ?></td>
<td style="text-align:right;"><?php echo $ro["semail"]; ?></td>
</tr>
<?
}
?>
Looks like you are using MySQL. Suggest you read this http://dev.mysql.com/doc/refman/5.6/en/charset.html.
Can you tell if MySQL is set up for unicode (international) character sets. You can use some of the MySQL admin tools to check this. YOu need to know the name of the character set you want to use, and check if it is loaded into your MySQL installation.
At the HTML level, you need to specify that you are using utf8 output by placing something like
in your header area
Hi i have one table in my database which has list of states and i want to fetch this data from the table but my query is not executing properly it gives me some error
<?php
require_once('../Config/database.php');
$result1=$this->Signup->query("SELECT * FROM states");
//echo $popular;
while($post = mysql_fetch_array($result1))
{ ?>
<table width="380">
<tr>
<td class="table_txt"><a class="thickbox tn" href="demo.php?state_name=<?php echo $post['state_name']?>&state_id=<?php echo $post['state_id']?>&height=430&height=430&width=700&inlineId=myOnPageContent"><?php echo $post['state_name']?></a></td>
</tr>
</table>
<?php }
?>
But it gives me error
Warning (512): Method SignupHelper::query does not exist [CORE\Cake\View\Helper.php, line 192
Warning (2): mysql_fetch_array() expects parameter 1 to be resource, null given
Please read the documentation first.
It seems you are trying to get the states, inside the View, with a query.
You need to separate the view from the model.
Create a State model.
Use something like this in your controller:
$this->loadModel('State');
$states = $this->State->find('list'); // this will create a key => value array with the IDs and names
$this->set('states', $states);
In your view, use
<table width="380">
<tr>
<?php foreach ($states as $stateId => $stateName) {
<td class="table_txt"><a class="thickbox tn" href="demo.php?state_name=<?php echo $stateName?>&state_id=<?php echo $stateId?>&height=430&height=430&width=700&inlineId=myOnPageContent"><?php echo $stateName ?>></a></td>
<?php } ?>
</tr>
You might still need some changes, but this is the main idea.
I am having a problem, i can connect to my database but it wont save in database what i wrote in a text area. Every time i click update it saves as blank, if i write lalala in mysql directly and refresh the page where text area is i can see lalala in text area but if i replace the text lalala in text area for something else and click update, it deletes the previous text lalala and leaves the field blank. Heres my code:
----------------------------- File 1 ---------------------------------
<?
include("header.inc.php");
$result5 = mysql_query("SELECT faq FROM `demo_a_faq`");
$myrow5 = mysql_fetch_row($result5);
$faq = $myrow5[0];
?>
<?
include("../templates/admin-header.txt");
?>
<form method="post" action="faq2.php">
<TABLE bgcolor="#FFFFFF" bordercolor="#000008" border="0" width="95%" align="center">
<TR>
<TD width="50%"><center><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <b>Edit FAQ:</b><br><textarea name="faneu" type="text" cols="80" rows="25"><? echo "$faq"; ?></textarea></TD>
</TR>
</TABLE><br><br>
<center><input type="submit" value="Update"></form></center>
<?
include("../templates/admin-footer.txt");
?>
----------------------------- File 2 ---------------------------------
<?
include("header.inc.php");
$asl = "UPDATE `demo_a_faq` SET `faq` = '$faneu'";
$results = mysql_query($asl) or die(mysql_error());
?>
<?
include("../templates/admin-header.txt");
?>
<center><br><br><br><b>Updated!</b></center>
<?
include("../templates/admin-footer.txt");
?>
In header.inc.php i simply have the conection to database.
Can someone please tell me why it is not saving what i write in text area to database as it is driving me crazy.
Thanks in advance
Try this:
<?php
include("header.inc.php");
// Always escape variables used in SQL-queries to avoid SQL-injections.
$faneu = mysql_real_escape_string($_POST['faneu']);
$asl = "UPDATE `demo_a_faq` SET `faq` = '$faneu'";
$results = mysql_query($asl) or die(mysql_error());
?>
<?
include("../templates/admin-header.txt");
?>
<center><br><br><br><b>Updated!</b></center>
<?
include("../templates/admin-footer.txt");
?>
You don't POST your textarea value to "FILES 2".Be carefull.
Hello I am creating a web page to add some information about given product.I need to enter id,name,description and image as information.I need the id to be auto generated.I am using jsp and database as access.I am fetching the count(*)+1 value from database and assigning to my html text box but its showing as null.can i get some help?
Code:
<body>
<%#page import="java.sql.*"%>
<%! String no; %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:pd");
ResultSet rs = null;
Statement st = con.createStatement();
String sql = ("select count(*)+1 from products");
st.executeUpdate(sql);
while (rs.next()) {
no=rs.getString("count(*)+1");
}
rs.close();
st.close();
con.close();
}
catch(Exception e){}
%>
<Form name='Form1' action="productcode.jsp" method="post">
<table width="1024" border="0">
<tr>
<td width="10"> </td>
<td width="126">Add Product: </td>
<td width="277"> </td>
<td width="583"> </td>
</tr>
<tr>
<td> </td>
<td>Product Id:</td>
<td><label>
<input type="text" name="id" value="<%= no%>"/>
</label></td>
<td> </td>
.... and so on
{..}.executeQuery("Select max(id) from tablename");
This will return the ID with the largest number. Its more efficient than select * from tablename order by id desc limit 1.
However, it looks like your trying to guess/generate an ID of an object which doesn't yet exist in the database. This isn't the best way, and you may find that the ID your generating may be different to that generated by your DB. It could also cause duplication errors if two people are trying to create two new objects at the same time.
I would suggest that you don't provide a product id until the "create product" button has been pressed. Use ##IDENTITY; in your SQL command to set the new ID to your product safely.
You wrote a query to get the data like this
String sql = ("select count(*)+1 from products");
st.executeUpdate(sql);
The statement
executeUpdate()
only used to do the operations like INSERT,UPDATE
try
rs=st.executeQuery(sql);
instead of executeUpdate()