
Drummin
Members-
Posts
1,004 -
Joined
-
Last visited
Everything posted by Drummin
-
Oh. I didn't realize we were dealing with different pages. Is there any reason the processing needs to be on a different page? You could always use a header("location: ") if you must, but I would just have the posted values process on the page where it will be used.
-
Rather than attempting to change the the action section of the form and passing value as get, just pick up posted value at the top of your page and use that variable for calling records etc. <?php if (isset($_POST['subcats'])){ $id_subcategoria=$_POST['subcats']; } ?> <html> <body> <form id="form1" name="form1" method="post" action="products_2.php"> <select name="subcats" class="subcatsSelectMenu" id="subcats" onchange="this.form.submit()"> <option value="">Ver placas por tipos</option> <?php do { ?> <option value="<?php echo $row_subcats_RS['id_subcategoria']?>"><?php echo $row_subcats_RS['subcategoria_esp']?></option> <?php } while ($row_subcats_RS = mysql_fetch_assoc($subcats_RS));$rows = mysql_num_rows($subcats_RS); if($rows > 0) { mysql_data_seek($subcats_RS, 0); $row_subcats_RS = mysql_fetch_assoc($subcats_RS); } ?> </select> </form>
-
Not sure if this would do what you want. if(isset($_SESSION['logged'])) { $book = '<form action="../cancel.php" method="POST"><input type="hidden" name="day" value='.$mon.' type="text"/><input type="hidden" name="month" value='.$month.' type="text"/><input type="hidden" name="year" value='.$year.' type="text"/><input type="hidden" name="book_id" value="mon11" type="text"/>'; $sql = "SELECT * FROM diary WHERE day = '$mon' AND studio_id ='mon11'"; $query = mysql_query($sql) or die (mysql_error()); if (mysql_num_rows($query) < 1){ $bgcolour="#5DFC0A"; $book .= '<input type="submit" name="submit" value="Book!"></form>'; }else{ $bgcolour="#FF0000"; $book .= '<input type="submit" name="submit" value="Cancel!"></form>'; } }//if(isset($_SESSION['logged'])) echo "<td rowspan='3' bgcolor=\"$bgcolour\">"; if (isset($book)) { echo $book; } ?>
-
Make sure form values match. Looks like you have "homepage" in your form and "home page" in processing. I would also use isset() so values not posted don't throw errors. Btw, method post in the form should be lower case to validate but should work regardless. So instead of using and else statement I would just use an if statement for each line and wrap it all in an isset() statement. You could also use a switch if want to look into that, but for now let's just get things working. <?php if (isset($_POST['display_button'])){ if($_POST['display_button'] == "homepage") { header("Location: test.htm"); exit; } if($_POST['display_button'] == "new entry") { header("Location: addDdr.php"); exit; } } ?>
-
That just a path issue relative to the page processing the code. Understand also, you'll to have these header("location:"); lines above anything that might be sent to the browser and it should be followed by exit; <?php if($_POST['display_button'] == "home page") { header("Location: test.htm"); exit; } else { header("Location: addDdr.php"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> etc.
-
Just based on what I've seen, this should work. <?php // Validate $_GET['x'] and $_GET['y']. if (isset($_GET['x'])) { $x = (int) $_GET['x']; } else { $x = 0; } if (isset($_GET['y'])) { $y = $_GET['y']; } else { $y = 0; } // If $x and $y aren't correct, redirect the user. if ( ($x > 0) && (strlen($y) == 32)) { $query = "UPDATE users SET active=NULL WHERE id='$x' AND active='$y'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); // Print a customized message. if (mysql_affected_rows() == 1) { echo "<br><br><h3>Your account is now active. You may now log in.</h3>"; } else { echo '<br><br><p><font color="red" size="+1">Your account could not be activated. Please re-check the link or contact the system administrator.</font></p>'; } } ?>
-
Well that should be straight forward to fix. What is your current code for receiving these GET values and what are you doing with them?
-
I made a site that all works off the index page and just loads any processing code above html and then content within page, based on page called with Get. I used session to store current page from get and reloaded immediately so, Get's weren't obvious or could be taken advantage of. These were of course checked against valid pages so anyone playing with get values didn't do anything. So basically heading, footer stayed the same and content just changed. Worked out well. "Parts" were stored in different directories based on the name of the pages. Anyway, that's what I did.
-
Any dangers of using get_included_files()? Seems like you'd need to do some excluding to avoid things like database access, footer, menus or other included parts though the function is cool. Wouldn't want to show things that otherwise would be hidden.
-
Not sure about an "automatic" way but how hard is it to add a variable at the top of each page? $pagename="index.php"; You could easily display or use this variable as needed.
-
Instead of fight this, is the program going to be hosted online? Then assuming you have your send mail scripts setup correctly, you should be fine. If you are going to be hosting the site on your local machine, then make sure you set it up your SMTP sever to do this. Just do a search for finding out more about this. https://www.google.com/search?q=requirements+to+send+email+from+local I would focus on making sure validation codes (URL) received will process as expected, validating user and their email account etc.
-
Or like this I guess. <?php //Page name test21.php //Personally I would open connection at the top of the page instead of within each query. /* $host = "localhost"; $login = ""; $dbpass = ""; mysql_connect("$host","$login","$dbpass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); mysql_select_db($database_organizazone_db, $organizazone_db); */ if (isset($_POST['submitvote'])){ foreach ($_POST['vote'] as $k => $id){ $newcount=$_POST['votecount'][$id][0]+1; $sql="UPDATE tbl_candidates SET votecount='$newcount' WHERE user_id='$id'"; mysql_query($sql) OR die(mysql_error()); } } //Personally would not use $_SERVER['PHP_SELF'] but submit to a named page. For this example I'll use test21.php ?> <html> <body> <form id="form_vote" name="form_vote" method="post" action="test21.php"> <table border="1"> <tr> <td> </td> <td>user_id</td> <td>l_name</td> <td>course_id</td> <td>yearlevel</td> <td>about</td> </tr> <?php $sql_candi="SELECT * FROM tbl_candidates"; $rs_candi=mysql_query($sql_candi) OR die(mysql_error()); while ($row_rs_candi = mysql_fetch_array($rs_candi)){ //Note: don't nest spans// echo "<tr> <td><input name=\"votecount[{$row_rs_candi['user_id']}][]\" type=\"hidden\" value=\"{$row_rs_candi['votecount']}\" /><input name=\"vote[]\" type=\"checkbox\" value=\"{$row_rs_candi['user_id']}\" /> <span class=\"checkboxMinSelectionsMsg\">Minimum number of selections not met.</span></td> <td><input name=\"candi\" type=\"text\" disabled=\"disabled\" id=\"candi\" value=\"{$row_rs_candi['user_id']}\" readonly=\"readonly\" /></td> <td>{$row_rs_candi['l_name']} {$row_rs_candi['f_name']} {$row_rs_candi['m_name']}</td> <td>{$row_rs_candi['course_id']}</td> <td>{$row_rs_candi['yearlevel']}</td> <td>{$row_rs_candi['about_me']}</td> </tr>"; } ?> <tr> <td colspan="6"><input type="submit" name="submitvote" value="Submit Your Vote" /></td> </tr> </table> </form> </body> </html>
-
Guess I jumped the gun on the last post. As we're using check boxes in this form, not every loop is passed so array keys don't match. You could query DB to find current count for selected person or pass the value as part of the value of the check box, then explode values for processing. The last option is what I've done here. <?php //Page name test21.php //Personally I would open connection at the top of the page instead of within each query. /* $host = "localhost"; $login = ""; $dbpass = ""; mysql_connect("$host","$login","$dbpass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); mysql_select_db($database_organizazone_db, $organizazone_db); */ if (isset($_POST['submitvote'])){ foreach ($_POST['vote'] as $k => $id){ $values=explode(",",$id ); $newcount=$values[1]+1; $sql="UPDATE tbl_candidates SET votecount='$newcount' WHERE user_id='{$values[0]}'"; mysql_query($sql) OR die(mysql_error()); } } //Personally would not use $_SERVER['PHP_SELF'] but submit to a named page. For this example I'll use test21.php ?> <html> <body> <form id="form_vote" name="form_vote" method="post" action="test21.php"> <table border="1"> <tr> <td> </td> <td>user_id</td> <td>l_name</td> <td>course_id</td> <td>yearlevel</td> <td>about</td> </tr> <?php $i=0; $sql_candi="SELECT * FROM tbl_candidates"; $rs_candi=mysql_query($sql_candi) OR die(mysql_error()); while ($row_rs_candi = mysql_fetch_array($rs_candi)){ //Note: don't nest spans// echo "<tr> <td><input name=\"vote[]\" type=\"checkbox\" value=\"{$row_rs_candi['user_id']},{$row_rs_candi['votecount']}\" /> <span class=\"checkboxMinSelectionsMsg\">Minimum number of selections not met.</span></td> <td><input name=\"candi\" type=\"text\" disabled=\"disabled\" id=\"candi\" value=\"{$row_rs_candi['user_id']}\" readonly=\"readonly\" /></td> <td>{$row_rs_candi['l_name']} {$row_rs_candi['f_name']} {$row_rs_candi['m_name']}</td> <td>{$row_rs_candi['course_id']}</td> <td>{$row_rs_candi['yearlevel']}</td> <td>{$row_rs_candi['about_me']}</td> </tr>"; $i++; } ?> <tr> <td colspan="6"><input type="submit" name="submitvote" value="Submit Your Vote" /></td> </tr> </table> </form> </body> </html>
-
A different way of doing it. I don't care for SERVER SELF or other things you had going. Why have htmlentities when updating a voting count with a checkbox? Anyway this is my version of what you're trying to do. <?php //Page name test21.php //Personally I would open connection at the top of the page instead of within each query. /* $host = "localhost"; $login = ""; $dbpass = ""; mysql_connect("$host","$login","$dbpass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); mysql_select_db($database_organizazone_db, $organizazone_db); */ if (isset($_POST['submitvote'])){ foreach ($_POST['vote'] as $k => $id){ $newcount=$_POST['votecount'][$k]+1; $sql="UPDATE tbl_candidates SET votecount='$newcount' WHERE user_id='$id'"; mysql_query($sql) OR die(mysql_error()); } } //Personally would not use $_SERVER['PHP_SELF'] but submit to a named page. For this example I'll use test21.php ?> <html> <body> <form id="form_vote" name="form_vote" method="post" action="test21.php"> <table border="1"> <tr> <td> </td> <td>user_id</td> <td>l_name</td> <td>course_id</td> <td>yearlevel</td> <td>about</td> </tr> <?php $sql_candi="SELECT * FROM tbl_candidates"; $rs_candi=mysql_query($sql_candi) OR die(mysql_error()); while ($row_rs_candi = mysql_fetch_array($rs_candi)){ //Note: don't nest spans// echo "<tr> <td><input name=\"votecount[]\" type=\"hidden\" value=\"{$row_rs_candi['votecount']}\" /><input name=\"vote[]\" type=\"checkbox\" value=\"{$row_rs_candi['user_id']}\" /> <span class=\"checkboxMinSelectionsMsg\">Minimum number of selections not met.</span></td> <td><input name=\"candi\" type=\"text\" disabled=\"disabled\" id=\"candi\" value=\"{$row_rs_candi['user_id']}\" readonly=\"readonly\" /></td> <td>{$row_rs_candi['l_name']} {$row_rs_candi['f_name']} {$row_rs_candi['m_name']}</td> <td>{$row_rs_candi['course_id']}</td> <td>{$row_rs_candi['yearlevel']}</td> <td>{$row_rs_candi['about_me']}</td> </tr>"; } ?> <tr> <td colspan="6"><input type="submit" name="submitvote" value="Submit Your Vote" /></td> </tr> </table> </form> </body> </html>
-
More than likely your array $arr is not closed. You have. Array ( [0] => Array ( [b_x] => 85 [b_y] => 71 ) [1] => Array ( [b_x] => 436 [b_y] => 130 ) I have Array ( [0] => Array ( [b_x] => 85 [b_y] => 71 ) [1] => Array ( [b_x] => 436 [b_y] => 130 ) )
-
All that I saw was missing was the start the variable $distance with. $distance=""; And as I don't see the code for the function "distance" I just modified the line so I could see the results which echoed out. distance(295,163,71,85)-distance(295,163,130,436)- So as far as I can see, each array value is being called. Not sure why you see the one. I'll look more.
-
Not sure if this gets you any closer to what you're looking for. <?php $arr=array( 0 => Array ( 'b_x' => 85, 'b_y' => 71 ), 1 => Array ( 'b_x' => 436, 'b_y' => 130 ) ); $b_x = 295; $b_y = 163; $distance=""; foreach($arr as $db) { $db_x = $db['b_x']; $db_y = $db['b_y']; $distance .= "distance"."($b_x,$b_y,$db_y,$db_x)" . "-"; } echo "$distance"; ?>
-
So it seems SENDING the email is the problem, correct? Maybe you need some header information to pacify your host sever. Something like this. $headers = "From: [email protected]\r\n"; $headers .= "Reply-To: [email protected]\r\n"; $headers .= "X-Sender: [email protected]\r\n"; $headers .= "X-Priority: 3 \r\n"; mail($_POST['email'], 'Registration Confirmed', $body, $headers);
-
Change this line if(!empty($username) && !empty($password)){
-
I also don't see where the variable $y is defined in the first bit of code before the insert and email.
-
Remove error suppression. @ Try adding this under your insert query to see if id is being grabbed. if (mysql_affected_rows() == 1) { $newid=mysql_insert_id(); echo "$newid"; }
-
You never fetched the row. <?php $host="localhost"; // Host name $username="user"; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $barcodeID=$_POST['barcode']; echo $barcodeID; $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); $row=mysql_fetch_row($result); if($count==1){ $_SESSION['barcode'] = $barcodeSession; $_SESSION['userlevel'] = $row['Priority']; if($row['userlevel'] == "Admin") { header("location:AdminSection.php"); }else{ header("location:index.php"); } header("location:LoggedIn.php"); } else { header("location:index.php"); } ?>
-
Are you saying the option should be catid like this? echo "<option value=\"{$row['id']}\"" . (isset($catid) && $catid=="{$row['id']}" ? ' selected="selected"' : '') . ">{$row['id']}-{$row['categories']}</option>\r";
-
I would wrap the first IF statement the receives the GET id so that it encloses the query so it's not run without an id. Sorry I didn't spot that before. <?php include("menu.php"); include("db.php"); if (isset($_GET['id']) && ctype_digit($_GET['id'])){ $id=$_GET['id']; $sql = "select * from links where id =$id"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $id = $row['id']; $catid = $row['catid']; $name = $row['name']; $url = $row['url']; $content = $row['content']; } }//if (isset($_GET['id']) && ctype_digit($_GET['id'])) if (isset($_POST['submit_changes'])){ //process update }//if (isset($_POST['submit_changes'])) ?> <html> <head> <title>Update</title> </head> <body> <form action="updated.php" method="post"> <table width="65%" align="center"> <tr> <td align="left"><input type="hidden" value="<?php if (isset($id){echo "$id";} ?>" name="id" /><b>Website Name:</b> <br />Change the name of the website listing.<br /> <input type="text" value="<?php if (isset($name){echo "$name";} ?>" name="name" /> <br> <br><b>URL:</b> <br>Change the URL of the website listing. <br><input type="text" value="<?php if (isset($url){echo "$url";} ?>" name="url"/> <br> <br><b>Description:</b> <br>Change the description of the website listing. <br>Limit 255 characters. <br/><textarea name="content" cols="45" rows="4" wrap="soft"><?php if (isset($content){echo($content);} ?></textarea> <br> <?php $result = mysql_query("SELECT id, categories FROM categories") or die(mysql_error()); echo "<select name=\"catid\">\r"; while ($row = mysql_fetch_array($result)) { echo "<option value=\"{$row['id']}\"" . (isset($id) && $id=="{$row['id']}" ? ' selected="selected"' : '') . ">{$row['id']}-{$row['categories']}</option>\r"; } echo "</select>\r"; ?> <div align="center"> <input type="submit" name="submit_changes" value="submit changes" /> </div></td> </tr> </table> </form> </body> </html>
-
You didn't indicate in your code what defines that. I would assume it is the level. Then adding an IF statement to check level within the result loop. <?php session_start(); include"database.php"; if (isset($_POST['login'])) { if (empty($_POST['email']) || empty($_POST['password'])) { $message="Please fill out all fields."; }else{ $email=mysql_real_escape_string($_POST['email']); $password=mysql_real_escape_string($_POST['password']); $sql="SELECT id,level,firstname FROM users WHERE email='$email' and password='".md5($password)."'"; $result=mysql_query($sql); if (mysql_num_rows($result)){ $row = mysql_fetch_row($result); if ($row[1]=="good Level"){ $_SESSION['user_id']=$row[0]; $_SESSION['user_level']=$row[1]; $_SESSION['user_first']=$row[2]; $message="You have successfully logged in!"; }else{ $message="You are not activated yet"; } }else{ $message="Wrong Email or Password!"; } } } ?> Not sure I have that all bracketed up right as I'm just adding things without testing anything.