Jump to content

New Coder

Members
  • Posts

    146
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

New Coder's Achievements

Member

Member (2/5)

0

Reputation

  1. I kinda see where you are going but I'm getting error: PHP Notice: Undefined variable: ref in C:\inetpub\wwwroot\test.php on line 5 on page 1 this is how page 1 looks at the moment: <?php session_start(); $a = rand(1,1000); for ($i = rand(1,10); $i < rand(11,20); $i++) $a += rand(1,rand(35,1000)); // KINDA ensures a random number $ref &= $_SESSION['tabs'][$a]; $ref = array(); // use $ref for the rest of STEP 1 $list = "<table>"; $list .= "<tr>"; $list .= "<th colspan=\"4\">Search for a Customer</th>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td></td><form action=\"test2.php\" method=\"post\">"; $list .= "<td>Forename (Leave blank for all)</td>"; $list .= "<td>Surname (Leave blank for all)</td>"; $list .= "<td></td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td>Name Search</td><form action=\"search_name.php\" method=\"post\">"; $list .= "<td><input type=\"text\" name=\"forename\" size=\"25\"></td>"; $list .= "<td><input type=\"text\" name=\"surname\" size=\"25\"><input type=\"text\" name=\"tab\" value=\"$a\"></td>"; $list .= "<td class=submit><input type=\"submit\" class=\"submit\" value=\"Search\"></form></td>"; $list .= "</tr>"; $list .= "</table>"; echo $list ?>
  2. Hello all, I hope someone can shed some light/point me in the right direction. I have a site that allows you to search for a customer then view and change their detail. page 1 has a search box for name entry. page 2 displays all the matches retrieved from a db table that match. The user selects which customer is the correct 1 and sets a cookie containing the selected customers unique id. page 3 allows changing of the customers details. now the problem I have: If a user navigates to page 3 and has a customers details on page for viewing all is well. If they open a new tab (leaving page 3 open on first tab) and go to page 1, search for another customer, page 2 select another customer (which overwrites cookie) then to page 3. They now have two tabs open on page 3 both displaying different customer details. If they return to the first tab and change some detail, when they save it actually updates the users details that corrispond to the second tab. I know this is because the cookie has been changed that holds the unique id that is required for the update query. How can I prevent this? I've looked at sessions but it would seem the same issue would excist. Am I wrong? Many Thanks I hope I made sense.
  3. Hello All, On my form I have 8 radio buttons one of which the value is "other" I have a text box next to "other" so that we can capture what the other might be. (Standard stuff I'm sure you've seen) I have got it so that the text box is enabled if they select the "other" radio button, but it's not being disabled again if they decide to pick a different option and my limited javascript knowledge,I'm stuck. Heres what I have so far: <script type="text/javascript"> var currentEnabled = null; function enableElement(elem) { if (currentEnabled) { currentEnabled.disabled = true; } elem.disabled = false; currentEnabled = elem; } </script> list .= "<tr>"; $list .= "<td class=table width=\"50%\"><input type=\"radio\" class=\"radio_button\" name=\"destination\" value=\"1\">Spain</td>"; $list .= "<td class=table width=\"50%\"><input type=\"radio\" class=\"radio_button\" name=\"destination\" value=\"2\">France</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td class=table width=\"50%\"><input type=\"radio\" class=\"radio_button\" name=\"destination\" onclick=\"enableElement(this.form.elements['other_desc'])\" value=\"99\">Other</td>"; $list .= "<td class=table width=\"50%\"><input type=\"text\" class=\"textdesc\" style=\"color:lightgrey\" size=\"50\" name=\"other_desc\" value=\"If other enter detail here\" disabled=\"disabled\" onfocus=\"if (this.className=='textdesc') { this.className = ''; this.value = '';this.style.color = 'black';}\" onblur=\"if (this.value == '') { this.className = 'textdesc'; this.value = 'If other enter detail here'; this.style.color = 'lightgrey'; }\" ></td>"; $list .= "</tr>"; Above is only a snipit :-) Any help much appreciated. Many Thanks
  4. Ill build a quotes table and do some test for you too and get back with what I come up with
  5. <?php $con = mysql_connect("localhost","quotesuser","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } $date = date("Y/m/d - H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; mysql_select_db("quotes", $con); $qd = mysql_real_escape_string($_POST['Quote_Data']); $qb = mysql_real_escape_string($_POST['Quoted_By']); $sql1 = "select * from Quotes where ip='$ip' and Date_Time = '$date'"; $rs = mysql_query( $sql1, $con ) or die( "Err: Query 1"); if(mysql_num_rows($rs)!=1) { $sql2="INSERT INTO Quotes (Quote_Data, Quoted_By , Date_Time, ip) VALUES ('$qd','$qb','$date','$ip')"; $rs = mysql_query( $sql2, $con ) or die( "Err: Query 2"); header("Location: select.php"); echo "Quote Added to Database."; } else { echo ("Sorry you have already made 1 quote today"); } mysql_close($con) ?>
  6. Ah right this is a page you've built linked from your IPB. I'm no expert on IPB's but if you can pass the logged on user you could then insert that into your table. If not I don't see why ip wouldn't work as a check. How ever you need an extra field in your quotes table for my suggested method to work. <?php $con = mysql_connect("localhost","quotesuser","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } $date = date("Y/m/d - H:i:s"); mysql_select_db("quotes", $con); $qd = mysql_real_escape_string($_POST['Quote_Data']); $qb = mysql_real_escape_string($_POST['Quoted_By']); $sql1 = "select * from Quotes where ip=$_SERVER['REMOTE_ADDR'] and Date_Time = $date"; $rs = mysql_query( $sql1, $con ) or die( "Err: Query 1"); if(mysql_num_rows($rs)!=1) { $sql2="INSERT INTO Quotes (Quote_Data, Quoted_By , Date_Time, ip) VALUES ('$qd','$qb','$date',$_SERVER['REMOTE_ADDR'])"; $rs = mysql_query( $sql2, $con ) or die( "Err: Query 2"); header("Location: select.php"); echo "Quote Added to Database."; } else { echo ("Sorry you have already made 1 quote today"); } mysql_close($con) ?> You can then change the query count slightly if you wanted to up the quotes allowed limit p.s code not tested as I dont have a quotes table
  7. Is the user logged in or anything? Because you could store who entered the quote and the date entered. You could then check if they have already entered a quote on that day. and if so say sorry already made a quote today. or check for a limit of x amount of quotes allowed on a day. Or like you say you could store the ip and use this to check too.
  8. I couldn't seem to get what I wanted so I used Javascript On the index page I added: <script type="text/javascript"> var WinNetwork = new ActiveXObject("WScript.Network"); var User_Name = WinNetwork.userName; window.location.href = "mainpage.php" + "?User_Name=" + encodeURIComponent(User_Name); </script> Then on mainpage I added: if($_GET['User_Name'] == "GenericAccName") { header("Location:genaccmain.php"); exit(); } Bit quick and dirty but until i find a better solution it's working to my needs. Many Thanks
  9. Yes, correct. I looked into that but could only find the ip which I can't use. $_SERVER['REMOTE_HOST'] Is there one for computer name? Many Thanks
  10. Hello all, This has probably been asked before but I couldn't find through search. And I'm pretty sure is not possible, but... Is there a way of displaying the windows logged on user? or get the name of the compter? as I know I can get the ip address. The reason I ask. Each user has their own network account but on occasion we need to log on a user as a generic account we have. And I want to check if it's this user accessing the page so different options etc can be displayed. I could use the computer name to check this as we log all activity. I could then query the log using the comp name to find logged on user. Unfortunately the log does not hold ip, which would seem obvious but it doesn't Many Thanks
  11. to get round you duplicate key issue: $sql="select * from Profile where username = '$username'; $result = mysql_query( $sql, $conn ) or die( "ERR: SQL 1" ); if(mysql_num_rows($result)!=0) { #do insert sql } else { #go here via header or display own message etc } hope that helps
  12. You need to put the text in the value too: <option value="10 1/1/1/0/shdsl">1/1/1/0/shdsl</option> <option value="12 1/1/2/0/shdsl">1/1/2/0/shdsl</option> etc etc Or you could create a lookup table that references the value. That way you can produce two variables, one with the value eg. 10 and one with the text item eg: 1/1/1/0/shdsl
  13. You could try $second_email = "mymail@gmail.com"; $send_to = $em. ", ". $second_email; $this->email->to($send_to);
  14. I dont use this type of email script but for mine I just seperate the addresses via a , so in your case i'd try: $second_email = "mymail@gmail.com"; $this->email->to($em, $second_email);
  15. You need to put the echo detail within the while loop otherwise I'm assuming it's only echoing the last record found or rarther than build the table every time you could just add to it like: <? $show = mysql_query("SELECT * FROM video_comments WHERE pageid='$vidid'"); $numrows = mysql_num_rows($show); if ($numrows > 0) { $list = "<table style='background-color:#FFF; border:#999 1px solid; border-top:none;' cellpadding='5' width='100%'>"; while($row = mysql_fetch_array($show)) { $userid = $row["userid"]; $username = $row["username"]; $comment = $row["comment"]; $date = $row["date"]; $date = strftime("%b %d, %Y", strtotime($date)); $list .= "<tr>"; $list .= "<td width='90%' valign='top' style='line-height:1.5em;'><span class='greenColor textsize10'>$date<a href='profile.php?id=$userid'> $username </a> said:</span><br /> $comment</td>"; $list .= "</tr>"; } $list .= "<table>"; echo ( $list ); } else { echo"<center><font face='arial' size='2'><p>This video has no comments.</font></center>"; } ?> Code not tested but should give you an idea
×
×
  • 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.