Jump to content

lovesuckstudio

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by lovesuckstudio

  1. ive tried it before, but it doesnt retrieve the value after form is submitted. i got this : INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (NULL, NULL, 2345)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (NULL, NULL, 7890)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (NULL, NULL, 8355)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (NULL, NULL, 8910)/ instead of this : INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (4, 1234, 2345)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (3, 1234, 7890)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (2, 1234, 8355)/INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (1, 1234, 8910)/ it seems like the original value of the text field.
  2. //to here from line 152 $stringtoken = $stringtoken.$str; this is line 48 /*from here*/ $str = $str.$insertSQL."/";//how to get this string value to line 47 this is line 152 sorry i didnt find the button to edit the code. this is dreamweaver generated code. yeah its quite long to read. sorry guys
  3. one more question, i cant get the value from line 152 to 48 cause the script is read from top to bottom, so i just try to post the value to other form in other page, but i cant get it too. how to get the value from "hidden_insertSQL" ? ive tried the echo, $_POST method but it just wont work. here is the code : <?php session_start(); if (isset($_SESSION['MM_Username'])){ //echo "<center>Selamat Datang, ".$_SESSION['MM_Username']; ?> <!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>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #33FF66; } .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; } --> </style></head> <body> <table width="980" height="261" border="0"> <form name="form_submit_rate" method = "post" class = "style1" id = "form_submit_rate" action = "ratestaffsuccess.php"> <tr> <td width="301" height="95"> </td> <td width="663"><input type="text" name="hidden_SQL" id="hiddenField" value="<?php $_POST["hidden_insertSQL";?>" /></td> </tr> <tr> <td height="158"><div align="right"><img src="images/warning.png" width="128" height="128" /></div></td> <td class="style1"><p>Your evaluation has successfully submitted. Thank you.</p> <p><a href="form_login.php">Click here to login</a></p></td> </tr> </form> </table> </body> </html> <?php } else { header ("Location: error.php"); } ?>
  4. You can't the script is read from top to bottom. okay. is there any other ideas?
  5. && If you have an if statement with variables in it that are not defined, there is nothing for the if statement to compare. So as a normal human being situation you ask someone: could you give me a glass of water if A = B ? that other person obviously will ask ok, but what is A and what is B? since they are not defined. if ( $a==$b ){ give_glass_of_water(); } So how to fix this, we define A and B $a = 5; // $a is now assigned with the value of 5; $b = 4; // $b is now assigned with the value of 4; if ( $a==$b ){ // here we compare the value of A with B give_glass_of_water(); }else{ echo 'no water for you mister!'; } Hope this clears the defining part a bit. thanks, now i get it clear
  6. i'm trying to get the value before the form has been submitted. but i just don't know how. i want when i clicked the submit button, the value get into the $stringtoken, then it will split into token and then run the sql. if there's any other idea, just say it. thanks guys .
  7. guide me for where i'm wrong. i cant see it. i think i have defined the $str = " "; when i clicked submit button, it appears at the textfield, but the sql statement in the $str doesnt appear at the $stringtoken. sorry if i'm asking a silly question. i'm very new in php. anyway thanks for the replies
  8. <?php session_start(); if (isset($_SESSION['MM_Username'])){ ?> <?php require_once('../Connections/spr.php'); ?> <?php require_once('spr.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_rate")) { //to here from line 152 $stringtoken = $stringtoken.$str; /* Use tab and newline as tokenizing characters as well */ $token = strtok($stringtoken,"/"); while ($token !== false) { //$in = $token; echo "$token<br />"; mysql_select_db($database_spr, $spr); $Result1 = mysql_query($token, $spr) or die(mysql_error()); // echo "Word=$tok<br />"; $token = strtok("/"); } } mysql_select_db($database_spr, $spr); $query_display_all = "SELECT * FROM staff WHERE Staff_ID != ".$_SESSION['MM_Username']; $display_all = mysql_query($query_display_all, $spr) or die(mysql_error()); $row_display_all = mysql_fetch_assoc($display_all); $totalRows_display_all = mysql_num_rows($display_all); ?><!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>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #33FF66; } .style1 {font-family: Verdana, Arial, Helvetica, sans-serif} --> </style></head> <body> <table width="985" border="0" align="left"> <form action="" method="POST" name="form_rate" class="style1" id="form1" > <tr> <th width="213" scope="col">Staff ID</th> <th width="238" scope="col">Staff Name</th> <th width="57" scope="col"> </th> <th width="64" scope="col"> </th> <th width="55" scope="col">Rate</th> <th width="51" scope="col"> </th> <th width="55" scope="col"> </th> <th width="218" scope="col">Comment/Remarks</th> </tr> <?php //loop starts here $i=1; $str = " "; $hidden_staff_voted_id_ = " "; do { ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="center"><?php echo $row_display_all['Staff_ID']; ?></div></td> <td><div align="center"><?php echo $row_display_all['Staff_Name']; ?></div></td> <?php $rate = "Radio_".$row_display_all['Staff_ID']?> <?php $staff_voted_id = $row_display_all['Staff_ID']; ?> <?php // $staff_vote_id = $_POST['MM_Username']; ?> <td> <input type="radio" name="<?php echo $rate ?>" id="Rate_1" value=1 />1 </td> <td> <input type="radio" name="<?php echo $rate ?>" id="Rate_2" value=2 />2 </td> <td> <input type="radio" name="<?php echo $rate ?>" id="Rate_3" value=3 /> 3 </td> <td> <input type="radio" name="<?php echo $rate ?>" id="Rate_4" value=4 /> 4 </td> <td> <input type="radio" name="<?php echo $rate ?>" id="Rate_5" value=5 /> 5 </td> <td><input type="text" name="comment" id="comment" /></td> </tr> <tr> <td><input name="hidden_Staff_Vote_ID" type="hidden" id="hidden_Staff_Vote_ID" value="<?php echo $_SESSION['MM_Username'] ?>" /> </td> <td> <input name="hidden_Rate" type="hidden" id="hidden_Rate" value="<?php echo $_POST[$rate]; ?>" /></td> <td><input name="hidden_Staff_Voted_ID" type="hidden" id="hidden_Staff_Voted_ID" value="<?php echo $staff_voted_id ?>" /></td> <?php $hidden_staff_vote_id = $_POST["hidden_Staff_Vote_ID"]; $hidden_staff_voted_id = $_POST["hidden_Staff_Voted_ID"]; $hidden_rate = $_POST[$rate]; ?> <input type="text" name="hidden" id="hiddenField2" value ="<?php $_POST[$rate];?>"/> <?php $insertSQL = sprintf("INSERT INTO vote (Rate, Staff_Vote_ID, Staff_Voted_ID) VALUES (%s, %s, %s)", GetSQLValueString($_POST[$rate],"int"), GetSQLValueString($_POST['hidden_Staff_Vote_ID'],"int"), GetSQLValueString($staff_voted_id,"int")); //string tokenizer for SQL statement /*from here*/ $str = $str.$insertSQL."/";//how to get this string value to line 47 $hidden_staff_voted_id_ = $hidden_staff_voted_id_.$staff_voted_id; ?> <?php $i++; } while ($row_display_all = mysql_fetch_assoc($display_all)); ?> </td> <td></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input type="text" name="textfield" id="textfield" value="<?php echo $hidden_staff_voted_id_ ?>" /> <input name="hidden_insertSQL" type="text" id="hidden_Rate_2" value="<?php echo $str ?>" /> </td> <td><input type="submit" name="Submit" id="Submit" value="Submit" /></td> <td><input type="reset" name="Reset" id="Reset" value="Clear All" /></td> <td> </td> <td> </td> <td> </td> <td><?php echo $token; ?> </td> </tr> <input type="hidden" name="MM_insert" value="form_rate" /> </form> </table> <p class="style1"> <input name="hiddenField" type="text" id="hiddenField" value="<?php echo $str ?>" /> </p> </body> </html> <?php mysql_free_result($display_all); //$stringT = $stringT.$string; ?> <?php } else { header ("Location: error.php"); } ?> My question is how to get the $str value from line 152 to line 48? thank you in advance guys
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.