
rik72
Members-
Posts
41 -
Joined
-
Last visited
Never
Everything posted by rik72
-
Okay, since earlier i am still stuck with it all. <h2>Current Orders</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE order_status != 3"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client ID</th> <th>Client Name</th> <th>Invoice Number</th> <th>Status</th> <th width='300px'>Notes</th> <th>Deadline</th> <th>Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='20px'>" . $row['client_id'] . "</td>"; echo "<td width='100px'>" . $row['client_name'] . "</td>"; echo "<td width='100px'>" . $row['invoice_number'] . "</td>"; echo "<td width='200px'>"; echo "<select name='order_status' id='order_status'>"; $result2 = mysql_query("SELECT * FROM order_status"); while($row2 = mysql_fetch_array($result2)) { echo "<option value='$row2[status_id]'"; if($row2['status_id'] === $row['order_status']) { echo "selected='selected'"; } echo "> $row2[order_status] </option>"; } echo "</select></td>"; echo "<td width='300px'><textarea name='notes'>" . $row['notes'] . "</textarea></td>"; echo "<td width='100px'>" . $row['deadline'] . "</td>"; echo "<td><input name='delete' type='checkbox' value='del' /></td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> <input type="submit" name="update" id="button" value="Update Orders" /> </form> This all works but i basically need an update statement so that i can change order_status's and notes within the table. If someone could point me in the right direction of how to go about it, that would be fantastic.
-
Error: Query was empty Thanks,
-
I dab into PHP probably once a year for small projects and i've gone very rusty! <?php if(isset($_POST['update'])) { $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); mysql_query("UPDATE order_manager SET order_status='$_POST[order_status]'"); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<div id='red'>order updated!</div>"; mysql_close($con); } ?> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE active='1'"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client Name:</th> <th>Invoice Number:</th> <th>Status:</th> <th>Notes:</th> <th>Deadline:</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['client_name'] . "</td>"; echo "<td>" . $row['invoice_number'] . "</td>"; echo "<td>"; echo "<select name='order_status' id='order_status'>"; echo "<option value='" . $row['status'] . "' selected='selected'>Payment Received</option>"; echo "<option value='Payment Received'>Payment Received</option>"; echo " <option value='Awaiting Payment'>Awaiting Payment</option>"; echo " <option value='Stock Ordered'>Stock Ordered</option>"; echo " <option value='Awaiting Digitising'>Awaiting Digitising</option>"; echo " <option value='Processing Order'>Processing Order</option>"; echo " <option value='Waiting for email from client'>Waiting for email from client</option>"; echo "</select></td>"; echo "<td>" . $row['notes'] . "</td>"; echo "<td>" . $row['deadline'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <input type="submit" name="update" id="button" value="Submit" /> </form> I know my dropdown box isn't ideal, but I'll work on that later on, i'm basically trying to make my table update the status when i hit submit. It's an internal system so it doesn't need to be perfect, but i'm currently just getting errors.
-
I have spent a further 20mins looking online and managed to solve my issue. This website had a good article on how to solve it! http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site
-
Hi, I am currently writing a code to rename my pages so index.php?page=product becomes /product etc. For this i found a snippet online which seems to work great. RewriteEngine on RewriteRule ^([^/\.]+)/?$ index.php?page=$1 My problem is, i would also like to extend this so that http://url.com/product/t-shirts does not have to be http://url.com/product&product=t-shirts, i have a column in my database called product_seo which has a url friendly version of each products title which is how "t-shirts" is pulling the information on t-shirts etc. Any help would be greatly appreciated! Rik
-
Thanks a lot, i've sorted the issue, the only thing i had to do is put mysql_close($db_handle); after the $emailCount function and it worked.
-
It's always going to 3, it's not adding to database. I changed the code to this since then (to try and self-troubleshoot it); $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if ('$SQL2' == '$_GET[email]') { echo 3; } else { $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } Now it's getting stuck at 1 (success), but it's not checking if the email address is already in the table, which is 3. Although it is doing error check 2 successfully.
-
Echo 1, 2, 3 is changed when it comes to the page... if (theResponse == 1) { $(".successBalloon").fadeIn("slow"); $(".successBalloon").animate({opacity: 1.0}, 3000); $(".successBalloon").fadeOut(1500); $(".resultText").html(successMessage); } if (theResponse == 2) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(invalidMailError); } if (theResponse == 3) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(duplicateMailError); }
-
Hi, i'm basically having problems with this code, its for a newsletter script which added the email address into a file, i'm trying to convert it to work with mysql but having a few problems; I've edited the last bit, the code just basically doesn't add it to the database even though i thought i had done it right... any help is very much appreciated! If email is not valid the script is letting me know; if email is valid it says "already added to the list" no matter what. old script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $f = fopen($newsletterFileName, 'a+'); $read = fread($f,filesize($newsletterFileName)); If (strstr($read,"@")) { $delimiter = ";"; } if (strstr($read,$email)) { echo 3; } else { fwrite($f, $delimiter . $email); echo 1; } fclose($f); } else { echo 2; } ?> edited script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter WHERE email = '$_GET[email]'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if (strstr($SQL2,$email)) { echo 3; } else { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } ?>