TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-20-2008, 03:04 PM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default form refresh problem

hi,

this form i made when i refresh witout entering anything a new row is created automatically. heres the code


ps:

in the first column, i tried to make the number a link but since its dynamic how do i make it a link to pull data from a row from the database.


Code:
<?php

$conn = mysql_connect("","","");
mysql_select_db("queue");

$queue_id = $_POST['queue_id'];
$status = $_POST['status'];
$datestart = $_POST['startdate'];
$dateend = $_POST['datestop'];
$domain = $_POST['domain'];
$company = $_POST['company'];
$assign = $_POST['assignby'];


if(isset($_POST['btn_submit'])) { 


#-----------------------------------------------
#		check for empty fields
#-----------------------------------------------

if(


!$_POST['queue_id']  ||
!$_POST['status']    ||
!$_POST['startdate'] ||
!$_POST['datestop']  ||
!$_POST['domain']    ||
!$_POST['company']    ||
!$_POST['assignby']    )




{ die('all fields are required go back and enter all the fields'); }


#-----------------------------------------------
#		security check
#-----------------------------------------------

$queue_id = addslashes($queue_id);
$status = addslashes($status);
$datestart = addslashes($datestart);
$dateend = addslashes($dateend);
$domain = addslashes($domain);
$company = addslashes($company);
$assign = addslashes($assign);


$queue_id = htmlentities($queue_id);
$status = htmlentities($status);
$datestart = htmlentities($datestart);
$dateend = htmlentities($dateend);
$domain = htmlentities($domain);
$company = htmlentities($company);
$assign = htmlentities($assign);




#-----------------------------------------------
#		save data
#-----------------------------------------------


$query = "INSERT INTO queue VALUES(null,'$queue_id','$status','$datestart','$dateend','$domain','$company','$assign')";
$save = mysql_query($query) or die(mysql_error());

}



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<style type="text/css">

th {
	 padding:8px;
	 background-color:navy;
	 border:1px solid black;
	 color:white;
}

td{
	
	padding:8px;
	background-color:#6699CC;
	border-left:1px dashed gray;
    border-right:1px dashed gray;
	color:white;
}

a:active,a {
	
	text-decoration:none;
	color:yellow;
	font-family:Verdana;
	font-size:10pt;
}

a:hover {
	
	text-decoration:underline;
	color:yellow;
	font-family:Verdana;
	font-size:10pt;
}



.style1 {
	background-color: #FFFF00;
}



</style>
</head>

<body>

<strong><span class="style1">&nbsp; Add a Request</span></strong><br />
<br />

<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<table>
<thead>
<tr>
<th>Queue #</th>
<th>Status</th>
<th>Date Started</th>
<th>Date Completed</th>
<th>Domain</th>
<th>Company name</th>
<th>Assigned by</th>
</tr>
</thead>



<tr>
<td><input type="text" name="queue_id"  style="width: 75px"></td>

<td><select name="status" style="width: 124px">
<option></option>
<option value="notstart">Not Started</option>
<option value="pending">Pending</option>
<option value="waiting">Waiting on someone</option>
<option value="complete">Completed</option>
</select></td>

<td><input type="text" name="startdate"></td>
<td><input type="text" name="datestop"></td>
<td><input type="text" name="domain"></td>
<td><input type="text" name="company"></td>
<td><input type="text" name="assignby"></td>

</tr>


</table>
<p>
<input type="submit" name="btn_submit" value="submit" style="width: 85px; height: 22px"></p>

<table>
<thead>
<tr>

<?php
$query_table = "SELECT * FROM queue ORDER BY 'queue_id'";
$result = mysql_query($query_table);

$header = "<p><strong><span class=\"style1\">Queue History</span></strong></p>";
$header .= "<th>Queue #</th>";
$header .= "<th>Status</th>";
$header .= "<th>Date Started</th>";
$header .= "<th>Date Completed</th>";
$header .= "<th>Domain</th>";
$header .= "<th>Company name</th>";
$header .= "<th>Assigned by</th>";



if(mysql_num_rows($result) == 0) {


echo "no records found";

}

else { 

echo $header;

}


?>




</tr>
</thead>

<?php

$query_table = "SELECT * FROM queue ORDER BY 'queue_id'";
$result = mysql_query($query_table);

if(mysql_num_rows($result)) {
$block = "<tbody><tr>";
while($row = mysql_fetch_assoc($result)) {

$block .= "<td><a href=\"edit.php?id=\"{$row['queue_id']}\">{$row['queue_id']}</a></td>";
$block .= "<td>{$row['status']}</td>";
$block .= "<td>{$row['date_started']}</td>";
$block .= "<td>{$row['date_end']}</td>";
$block .= "<td>{$row['domain']}</td>";
$block .= "<td>{$row['company']}</td>";
$block .= "<td>{$row['assigned_by']}</td>";
$block .= "</tr></tbody>";

}
echo $block;

}

?>










</form>
</body>

</html>
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 02-20-2008, 03:14 PM   #2 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 10
Thanks: 0
Pete is on a distinguished road
Default

by new row do you mean it inserts into your database but blank?
Pete is offline  
Reply With Quote
Old 02-20-2008, 04:55 PM   #3 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

If it reenters a copy of the row on refresh, make a check that checks to see if there is a row already with those values and if there is don't enter it!
Gareth is offline  
Reply With Quote
Old 02-21-2008, 03:47 AM   #4 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

here is a before and after screenshot of what happends.

here is the before screenshot
(i entered data into the field above and press submit and that new row got created.)


and when after that row is created if i click on the refresh button on the browser (automatically) the data is re-submited and creating the row again.

__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 02-21-2008, 12:09 PM   #5 (permalink)
The Contributor
 
flyingbuddha's Avatar
 
Join Date: Jan 2008
Location: Birmingham, UK
Posts: 60
Thanks: 10
flyingbuddha is on a distinguished road
Default

You could do one of a couple of things to prevent double-posts.

1. Before submitting your new data, check the last record's field contents aren't exactly the same as the one previous. (Not very fail-safe)

2. Issue a header to redirect to the current page:
PHP Code:
// not a great example as I'm not sanitizing the url
header("Location: {$_SERVER['PHP_SELF']}");
exit; 
__________________
Pro. Geek
http://www.mikeholloway.co.uk
flyingbuddha is offline  
Reply With Quote
Old 10-18-2012, 02:23 PM   #6 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default

Some conservatives have Coach Factory Outlet pushed that critique further, saying that Mr. Obama’s policies are too costly, often assist the wrong people Louis Vuitton Belts and could have the paradoxical effect of driving up college costs. The dispute turns not just on different Coach Factory Outlet assessments of how policies play out, but on differing philosophical views about the role of government. During Gucci Belts his time in office, Mr. Obama has sharply increased aid to low- and middle-income students, notably through the Pell Grant Coach Factory Outlet program, which grew from $14.6 billion given to 6 million students in 2008, to nearly $40 billion for Coach Factory Outlet almost 10 million students this year. His administration also made it easier to request aid, shortening the Coach Factory Online complex federal application and allowing people to transfer their financial information electronically from the Internal Coach Outlet Online Revenue Service database. But while many education experts laud his efforts, analysts of varying political Coach Outlet Online stripes have also questioned how much impact some of the president’s policies will have, noting that the prices Coach Online Outlet charged by colleges, and student borrowing, continue to climb.But behind the headlines about soaring costs, the Coach Factory Outlet Online reality is more complex and wildly uneven, because a growing number of students receive Coach Outlet Online financial aid, and only relatively high-income families pay those fast-rising sticker prices. Adjusted for Coach Factory Online inflation, the College Board calculates, the average net price changed little over the last decade at private Coach Factory Outlet schools, and rose only modestly at public ones.Defending federal spending, Arne Duncan, the secretary of Hermes Belts education, said that for more than 30 years, college prices had risen even when federal aid had not, leading him to believe Coach Factory Online there was zero correlation.
dashixiong is offline  
Reply With Quote
Old 10-22-2012, 09:52 AM   #7 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default Coach Outlet Online

when I go home.Coach Outlet It’s a big part of what I find addictive about living and working inCoach Outlet Store Online this part of the world. You feel like you’re watching the future unfold.Coach Factory Online for the US Open with no success."I prefer to go day-by-day without setting objectives orCoach Factory Online time frames, work hard on my recovery and make sure I keep on getting better little by little."Nadal has been forced Coach Outletto watch from the sidelines as longtime rival Roger Federer returned Coach Purse Outlet Onlineto the top of the world rankings after winning Coach Factory Outlet Onlinea seventh Wimbledon singles title.He has also seen Britain's Andy Murray,Coach Bags Outlet Online who won the men's singles gold medal at the 2012 Olympic Games, move above him in the world rankings after securing hisCoach Handbags Outlet first grand slam title at last month's U.S. Open.Currently ranked fourth in the world, Nadal has qualified to play at November's season-ending ATP World Tour Finals in London, Coach Outlet Onlinebut his ability to take part is in doubt due to his injury problems, admitting that his knee is still "bothering him".
dashixiong is offline  
Reply With Quote
Old 11-16-2012, 11:54 AM   #8 (permalink)
The Addict
 
Join Date: Nov 2012
Posts: 331
Thanks: 0
shui1880 is on a distinguished road
Default

Need some cool and refreshing water http://www.drdreheadphones-sale.net fun this summer to beat the heat in Georgia? We have just what you are looking for! Tubing, kayaking, water slide, hot tub cabins, Dr Dre Headphones and indoor & outdoor swimming pools are waiting for you all in one spectacular location at the Coosawattee River Resort in Ellijay. Whether the excitement of dr dre beats
a monster water slide Dr Dre Beats or the relaxation of a float down the Coosawattee River, we have the way for you to soothe that sweltering summer sizzle.
shui1880 is offline  
Reply With Quote
Old 01-29-2013, 01:04 PM   #9 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default

Organizers said Coach Outlet Online was opportune because the battle’s 150-year anniversary is in December, and Fredericksburg Coach Factory Outlet has been preparing to mark the sesquicentennial. in the new agreement is that Coach Outlet Online revolutionary councils from 14 Syrian provinces now each have a representative, though not all live Coach Online Outlet in Syria. The hope is that will bind the coalition to those inside the country. Perhaps Coach Bags Outlet the most important body the new group is expected to form is a Revolutionary Military Council Coach Factory Online to oversee the splintered fighting organizations and to funnel both lethal and nonlethal Coach Factory Outlet military aid to the rebels. It should unite units of the Free Syrian Army, various militias Coach Outlet Store Online and brigades in each city and large groups of defectors. Before the ink was even dry on the Coach Outlet Store final draft, negotiators hoped that it would bring them the antiaircraft missiles they crave to Coach Factory Stores take on the Syrian Air Force. The United States and Britain have offered only Coach Handbags Outlet nonmilitary aid to the uprising. A similar attempt by the Syrian National Council to Coach Factory Store supervise the military never jelled. Organizers said funding was too haphazard. Eventually foreign Coach Factory Online governments like Qatar and Saudi Arabia, which are financing and arming the rebels, found Coach Factory Online their own favorite factions to deal with. Foreign leaders notably including Secretary of State Coach Outlet Hillary Rodham Clinton urged this unification largely so they could coordinate their Coach Factory Outlet efforts and aid through a group of technocrats. Once it receives international recognition, the Coach Outlet Store Online coalition is supposed to establish a temporary Coach Outlet Online military never jelled.
dashixiong is offline  
Reply With Quote
Old 02-01-2013, 11:01 AM   #10 (permalink)
The Contributor
 
Join Date: Feb 2013
Posts: 32
Thanks: 0
sara111 is on a distinguished road
Default

Our Recruitment Business Management Outsourcing Group combining unparalleled experience, comprehensive capabilities across all industries and business functions, and extensive research on the world's most successful companies.
job agencies
employment agency
independent recruiting services
job recruiting services
candor agency
sara111 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design