Jump to content

cspgsl

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by cspgsl

  1. I have found a php script that allows a user to download a file and then prevent further downloads for a set amount of time. You can find it here http://www.web-development-blog.com/archives/limit-the-number-of-downloads-per-client/ As I am not very strong in coding, I am hoping with some assistance to modify the concept so that it will not allow a registered user to print a coupon I offer more than once. The process would work as such: the user registers (I am developing in Joomla using the Community Builder login / member component) the user clicks a link in the activation email welcome page opens with a link to the coupon user clicks the coupon link the link opens a page with the coupon and a print button in the same window to get around a popup blocker user clicks the print button and the page prints out the coupon print button also advances the page to a thank you page if the user clicks on the back button to access the link again the script prevents the user from opening the coupon window again with the message that there is only one coupon per user) I am assuming that this is doable but don't mind being told otherwise. I would be very grateful if there are any coders out there that could assist. Thanks
  2. it was really just a matter of closing and reopening the php tags. it then worked fine. so simple... thanks for the response
  3. the following error is returned from the code below Parse error: syntax error, unexpected '<' in ....line 19 the problem is between the <span></span>tags darned if i can see it... i'm too new [code] <? if ($_SESSION['loggedin'] === true):     //do nothing elseif (remembereduser()):     loginremembereduser(); else:     $form="";     render_login_form(); endif; function render_login_form() {     global $form;     $attribs = array();     require_once "HTML/QuickForm.php";     $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'],"",NULL,TRUE);     $form->addElement("header", "","Login here");     $form->addElement("hidden","freshtest", getfreshtestid()); <span style="color:darkblue;"<?Hello : =empty($_SESSION['bsd_username'])?>" We'd really like to learn your name.  Please login or register" : $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" > </span> $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" ?</span>     $form->addElement("text", "username", "Username:", $attribs);         $form->addElement("password", "pwd", "Password:", $attribs);     $form->addElement("checkbox", "rememberme", "", "Remember me", $attribs);     $buttons[] = &HTML_QuickForm::createElement("reset", "reset", "Clear");     $buttons[] = &HTML_QuickForm::createElement("submit", "submit", "Login");     $form->addGroup($buttons, null, null, " ");     $form->addElement("link", "","", FULLPATH."?action=forgottenpassword","Forgotten your password?", $attribs);     $form->addRule("username", "You must supply a username", "required");     $form->addRule("pwd", "You must supply a password", "required");     $form->registerRule('freshtest', 'callback', 'isfreshsubmission');     $form->registerRule('passwordverify', 'callback', 'verifypassword');     $form->addRule("freshtest", "You cannot use the backbutton to login", "freshtest");     $form->addRule("pwd", "Either the username or password is incorrect", "passwordverify");             if ($form->validate()):         return $form->process("login");     else:         $contents = '<div class="loginform">'. $form->tohtml().'</div>';         require_once "template.php";         exit;     endif; } function login($value=null){     global $form;     unset($_SESSION['freshtest']);     $_SESSION['loggedin'] = true;     $_SESSION['username'] = $form->exportvalue("username");     $rm = &$form->getelement("rememberme");     setrememberme($rm->getchecked()); } function setrememberme($state) {     global $db, $dbusertable;     if ($state === true):         $str =  "setting oookie";         $expiry = time() + 31536000;         $dbexpiry = $expiry;     else:         $str =  "deleting cookie";         $expiry = time()  -3600;         $dbexpiry = null;     endif;     $result = $db->query("update $dbusertable set rememberme=? where username=?", array($dbexpiry, $_SESSION['username']));     setcookie("bsd_username", $_SESSION['username'], $expiry); } function remembereduser() {     global $db, $dbusertable;     if (!isset($_COOKIE['bsd_username'])) return false;     $num = $db->getOne("Select count(*) from $dbusertable where username=? and rememberme > ?", array (trim($_COOKIE['bsd_username']), time()));     return ($num == 1); } function loginremembereduser() {     $_SESSION['loggedin'] = true;     $_SESSION['username'] = trim($_COOKIE['bsd_username']);     setrememberme(true); }     function verifypassword($value) {          //note you cannot use this for crypted passwords, but md5 passwords work ok.          global $form, $db, $dbusertable;     $pwd=trim($value);     $submittedusername = trim($form->exportvalue("username"));     $num = $db->getOne("select count(*) as cnt from $dbusertable where username=? and pwd=?", array($submittedusername, md5($pwd)));     return  ($num == 1); } function logout() {     unset ($_SESSION['username']);     unset ($_SESSION['loggedin']);     setrememberme(false); } ?> [/code]
  4. Sorry, I am afraid you lost me. Are you suggesting that I use the code as in the following post? (your quote): [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]but work on the following posted code: [a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=92839&view=findpost&p=371846\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=371846[/a] [/quote] That is going back to the beginning, isn't it? [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]I see you have fallen back to another one :)[/quote] I am using the last one you sent with the opening comments[code]//require("secret/db_connection.php"); // $kt_login_user = "tom"; // replaces the SESSION to test [/code] I also tried the code you sent where you indicated there was a parse error [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=92839&pid=371771&mode=threaded&show=&st=30&#entry371771\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...30&#entry371771[/a][/quote] and I was indicating that it was returning the contents of the user's record without error. The only thing was if I changed it it was not updating the user's record. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Remember also that when you set/start a new session, it wont take effect untill the next pageload, meaning setting a session and using it on the same code without reloading the page wont work[/quote] Are you referring to seeing the changes made without logging out and restarting the session? i am beginning to think you might have several different issues [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] not the leaset of which is being very green[/quote] that all needs to be fixed Thanks
  5. Good morning again. It's now questionable as to who I am talking with more... you or my wife #lol It would appear that this change has made all the difference with respect to eliminating any errors on opening the update page. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] try changing --> require_once('../../Connections/connBSD.php'); to --> require('../../Connections/connBSD.php'); [/quote] I added this too [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Also change your content of connBSD.php to this $selectDB = mysql_select_db("$database_connBSD") or die("Unable to select db"); [/code][/quote] I went back and inserted your post from yesterday morning (below) where you indicated there was a parse error and it is now working without error except that it isn't updating the user's record. [code]  <?php print "<p> </p>"; if(isset($_POST['update'])) { $new_msg = htmlspecialchars($_POST['welcome']); $sql = mysql_query("update users set welcome = '$new_msg' where username = '$kt_login_user'"); if($sql) {   print "<b>Saved!</b>"; } } $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user' limit 1"); $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; if(!$kt_welcome) { $kt_welcome = "My default text"; } echo <<<__HTML_END <form method="post" action="entree.php"> <textarea name="welcome" cols="80" rows="20">$kt_welcome</textarea> <br /> <input type="submit" name="update" value="Save" /> </form> __HTML_END; mysql_close(); ?> [/code] Also, your last code starting [code]// require("secret/db_connection.php");[/code] also works but, it does not updating the user's record either. I have printed out your code and I am now trying to understand what each line does. I'm sure I will be back to you with questions.
  6. [code] <? session_start();         if (!isset($_SESSION['kt_login_user'])):         $_SESSION['kt_login_user'] = "Anonymous";         $_SESSION['kt_name'] = $_POST['kt_name'];         $_SESSION['kt_welcome'] = $_POST['kt_welcome']; endif; error_reporting(E_ALL); ?> <?php require_once('../../Connections/connBSD.php'); ?> [/code] Contents of Connections/connBSD.php [code]<?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_connBSD = "localhost"; $database_connBSD = "pencils_users"; $username_connBSD = "pencils_cspgsl"; $password_connBSD = "drtlk001"; $connBSD = mysql_pconnect($hostname_connBSD, $username_connBSD, $password_connBSD) or trigger_error(mysql_error(),E_USER_ERROR); ?>[/code] The No database selected only appears after I click on Save. Even then, the echo $kt_login_user; returns a result Wife is off antique hunting and has the dog's leads in the car... no my fault. I let them out in the backyard, that should keep the carpets clean but there goes the grass (oh my). See last post [!--quoteo(post=371867:date=May 6 2006, 03:56 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 6 2006, 03:56 PM) [snapback]371867[/snapback][/div][div class=\'quotemain\'][!--quotec--] could you provide how you connect to your db, and if you are including this as a file with include(), require(), require_once() etc.[/quote] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]using --> require("path/dbfile.php"); where dbfile.php contains my previous db connection setup is tested and is working. Form action you put to $_SERVER[PHP_SELF] or the actual name you have chosen for this file, for example "update_welcome.php" or whatever.[/quote] I changed it to return to the page opened from logging on (with the multiple links)
  7. [!--quoteo(post=371861:date=May 6 2006, 03:31 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 6 2006, 03:31 PM) [snapback]371861[/snapback][/div][div class=\'quotemain\'][!--quotec--] If your session username finds a valid user it should work - the code i suplied has form action pointed on itself - one file handling both view stored and update. You dont get any mysql errors either ?? [/quote] If you are referring to [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]action="this_page.php"[/quote] it consistently returns "No Database selected" regardless of teh user I log in with. My process goes from a login page to a page with sevearl links, one of which is a link to the update page (there will be a few update pages by the time I'm done). Could it have anything to do with that? I don't get the mysql error that the @ sign fixed (the @ sign is [u]no longer[/u] in the page) Alpine: I have to walk the dogs or else they will pee on my carpets and the wife will get mad; you know, she who must be obeyed... Back in about an hour. Thanks.
  8. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] dont worry - we are solving a problem. [/quote] Humble thanks [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]end a variable set with ;[/quote] I should have caught that one... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]no misspelling in column names used?? [/quote] I take it that the names are as in the session list in the bindings window (I am using Dreamweaver MX and MX Kollection). There are no errors as the selections are made from the session in bindings [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--](don't mis-use @)[/quote] good point, thanks [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] following i have tested[/quote]I took this and pasted it into the page changing the form action to a page in my site. Upon opening the page the text from the user's record is there and has not failed. When I click Save it opens the file I specified. In reading through the code it would appear that it should update the record however, it does not. Instead what happens is if I go back to the update page I get a message "No database selected" and the balance of the page below echo $kt_login_user; is blank (view source reveals no content). If I click on Back and then return to the update page the same No database message is there. It requires logging out once to reset it to work again. In any event, the field is not updated.
  9. Good day Alpine, it seems you sleep like I do. Your last code yesterday was working brilliantly until I resumed my online session this morning. For whatever reason the code broke overnight (internet gremlins???) which is strange as it worked for the hour or so of testing done at the end of yesterday's dialogue. The message I was getting this morning [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pencils/public_html/interview/home_page.php on line 56 [/quote] was familiar so I placed an @ sign in front of [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]mysql_fetch_array($qry);[/quote] and it resolved the problem and it worked for a short time. I then retested it several more times. Logged in and out several times, closed and re-opened the browser, tried it in IE and FX and Netscape and found that "My default text" is returned regardless of the user. I tried your latest post but get the following error [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected T_VARIABLE in /home/pencils/public_html/interview/home_page.php on line 57[/quote] where this is the line of offending line [code]$sql = mysql_query("update users set welcome = '$new_msg' where username = '$kt_login_user'"); [/code] Sorry to be such a pain...
  10. I have always thought it better to be born lucky than smart however, this learning curve is very enjoyable. I would just like to learn at a little more competent rate though... That seems to have resolved it, [b]thank you, thank you[/b] Now if someone could point me in the direction of creating an update record form and incorporating the code I could go to bed and actually sleep tonite. [!--quoteo(post=371715:date=May 5 2006, 05:24 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 5 2006, 05:24 PM) [snapback]371715[/snapback][/div][div class=\'quotemain\'][!--quotec--] As far as i know, no-one is born with programming skills :) - we all learn something new almost every single day we do this. [/quote]
  11. Apart from the code, I must admit that I'm having trouble visualizing how to put this in an update record form...
  12. Sorry... back to the original scenario... now only returning "MY default text" for both users [!--quoteo(post=371706:date=May 5 2006, 05:03 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 5 2006, 05:03 PM) [snapback]371706[/snapback][/div][div class=\'quotemain\'][!--quotec--] *lol* so simple and yet so hard - but THIS TIME..... [code] <?php $kt_welcome = "My default text"; echo $kt_login_user; print "<p>&nbsp;</p>"; $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user' limit 1"); if($qry) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $kt_welcome; ?></textarea> <?php mysql_close(); ?> [/code] [/quote]
  13. Same problem, not returning "My default text" when field is empty. I tested it by putting something into the empty field and it returned the new value. I very much appreciate everyone's time btw. [!--quoteo(post=371700:date=May 5 2006, 04:54 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 5 2006, 04:54 PM) [snapback]371700[/snapback][/div][div class=\'quotemain\'][!--quotec--] okay, something weird with your num_rows, and thats causing your problem, new one here: [code] <?php echo $kt_login_user print "<p>&nbsp;</p>"; $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user' limit 1"); if($qry) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; if(!$kt_welcome OR $kt_welcome =="") { $kt_welcome = "My default text"; } } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $kt_welcome; ?></textarea> <?php mysql_close(); ?> [/code] !$kt_welcome OR $kt_welcome =="" checks if variable dont exist or is empty/doesnt contain any values (you can prefer to use the function empty() in some cases) I assume you only have unique usernames in your db.... else this will fail for sure [/quote] only two usernames and they are unique
  14. Hope I haven't upset anyone...
  15. [!--quoteo(post=371682:date=May 5 2006, 04:06 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 5 2006, 04:06 PM) [snapback]371682[/snapback][/div][div class=\'quotemain\'][!--quotec--] unless i misunderstood this problem, i suggest: [code] $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user'"); if(mysql_num_rows($qry) == 1) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; if(!$kt_welcome OR $kt_welcome =="") { $kt_welcome = "My default text"; } } [/code] ** EDITED a query cut'n paste error *lol* [/quote] I changed the code to reflect your edit I received [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pencils/public_html/interview/home_page.php on line 47 [/quote] so I added @ to [code]if(@mysql_num_rows($qry) == 1)[/code] With the change to your suggested the problem is reversed. Now the textarea contains the correct data for the user with data in the field and no entry for the user with no data in the field (which I assume is returning what it sees (empty) in the field. It should return "My default text" if there is no data in the users field. Code update: [code]<?php echo $kt_login_user ?> <p>&nbsp;</p> <?php $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user'"); if(@mysql_num_rows($qry) == 1) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; if(!$kt_welcome OR $kt_welcome =="") { $kt_welcome = "My default text"; } } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $kt_welcome; ?></textarea> <?php mysql_close(); ?> [/code] Alpine: I don't understand this line [code]if(!$kt_welcome OR $kt_welcome =="") [/code]
  16. Reposting code [code]<? session_start();         if (!isset($_SESSION['kt_login_user'])):         $_SESSION['kt_login_user'] = "Anonymous";         $_SESSION['kt_name'] = $_POST['kt_name'];         $_SESSION['kt_welcome'] = $_POST['kt_welcome']; endif; error_reporting(E_ALL); ?>[/code] [code]<?php echo $kt_login_user ?> <p>&nbsp;</p> <?php $sql = "SELECT 'welcome' FROM 'users' WHERE 'username' = '$kt_login_user'"; $qry = mysql_query($sql); if(@mysql_num_rows($qry) > 0) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; } else { $kt_welcome = "My default text"; } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $kt_welcome; ?></textarea> <?php mysql_close(); ?>[/code]
  17. [!--quoteo(post=371675:date=May 5 2006, 03:58 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 5 2006, 03:58 PM) [snapback]371675[/snapback][/div][div class=\'quotemain\'][!--quotec--] You're setting a normal variable and echoing a session variable. Replace it with the following. [/quote] Same I'm afraid
  18. [!--quoteo(post=371667:date=May 5 2006, 03:46 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 5 2006, 03:46 PM) [snapback]371667[/snapback][/div][div class=\'quotemain\'][!--quotec--] so let me get this straight: if the user puts something in the textbox that stores it in the 'welcome' column, when you check to see if there is an entry in 'welcome', if it exists, it's supposed to make $kt_welcome = $r['welcome'] but if not then it simply makes $kt_welcome = 'My default text." [/quote] Boy, am I new... I haven't got to creating the update form yet although I would think that to be the least of my worries. If I get the correct data in the text area when the query is run then I figure that taht is working (maybe I'm wrong here) [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]so as of right now, you are saying that your script does indeed print out "My default text" when it is supposed to, but it is blank when there is something in the 'welcome' column?[/quote] No, right now it only prints My default text. It should print "Bill's data" when user #2 is logged in and My default text when #1 is logged in. Could you please explain [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] 1) You're setting this: $kt_welcome; You're echoing this: echo $_SESSION['kt_welcome']; Those are not the same. [/quote] Changed but result the same [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?php echo $kt_login_user ?> <p>&nbsp;</p> <?php $sql = "SELECT 'welcome' FROM 'users' WHERE 'username' = '$kt_login_user'"; $qry = mysql_query($sql); if(@mysql_num_rows($qry) > 0) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; } else { $kt_welcome = "My default text"; } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $_SESSION['kt_welcome']; ?></textarea> <?php mysql_close(); ?> [/quote]
  19. [!--quoteo(post=371655:date=May 5 2006, 03:25 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 5 2006, 03:25 PM) [snapback]371655[/snapback][/div][div class=\'quotemain\'][!--quotec--] so the column in your database that you use to hold the user name is called 'id'? just making sure, because most people use 'id' for an id number not the user name. in other words, are you sure it's not supposed to be: SELECT 'welcome' FROM `users` WHERE `[!--coloro:red--][span style=\"color:red\"][!--/coloro--]username[!--colorc--][/span][!--/colorc--]` = '$kt_login_user' or some other such column name? [/quote] Doh... however, I changed it to [code]<?php $sql = "SELECT 'welcome' FROM 'users' WHERE 'username' = '$kt_login_user'"; [/code] but the results are the same here is the structure of the table [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Field Type Null Default id int(11) No username varchar(32) No password varchar(32) No name varchar(50) No lastname varchar(50) No email varchar(50) No designation varchar(50) Yes NULL firm varchar(50) No address varchar(50) No box varchar(50) Yes NULL suite varchar(20) Yes NULL city varchar(20) No province varchar(20) No postalcode varchar(20) No phone varchar(20) No fax varchar(20) Yes NULL level varchar(10) No active varchar(50) No user random varchar(50) No regtime datetime Yes 0000-00-00 00:00:00 welcome text No [/quote] The code re-posted [code]<? session_start();         if (!isset($_SESSION['kt_login_user'])):         $_SESSION['kt_login_user'] = "Anonymous";         $_SESSION['kt_name'] = $_POST['kt_name'];         $_SESSION['kt_welcome'] = $_POST['kt_welcome']; endif; error_reporting(E_ALL); ?> [/code] [code] <?php echo $kt_login_user ?>    <p> </p> <?php $sql = "SELECT 'welcome' FROM 'users' WHERE 'username' = '$kt_login_user'"; $qry = mysql_query($sql); if(@mysql_num_rows($qry) > 0) { // you have a result while($r = mysql_fetch_array($qry)) { $kt_welcome = $r['welcome']; } } else { $kt_welcome = "My default text"; } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $_SESSION['kt_welcome']; ?></textarea> <?php mysql_close(); ?> [/code]
  20. [!--quoteo(post=371650:date=May 5 2006, 03:04 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 5 2006, 03:04 PM) [snapback]371650[/snapback][/div][div class=\'quotemain\'][!--quotec--] so this didn't work either? you still need them so leave them there. try echoing $kt_login_user see if it's containing the value you want it to contain. maybe it's somehow not being passed right, so nothing is being selected from the db. [/quote] Yes, it returns the username (this is a positive thing)
  21. In the database fields one user's record has "This the text in the database" and the other user's record is blank
  22. Thanks but that didn't make any difference. [!--quoteo(post=371621:date=May 5 2006, 02:01 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 5 2006, 02:01 PM) [snapback]371621[/snapback][/div][div class=\'quotemain\'][!--quotec--] Change: $r[1]; To: $r[0]; You're only selecting one field from the database and the fetch_array function starts the array at 0. [/quote]
  23. I need an update form on a page that will look to see if anything is entered in the users "welcome" field in their record and, if there is content, display it for editing / updating. If there is nothing in the user's field enter "My Default Text" and use that to update the user's welcome field in their record. Thus far I have the following. In the login form [code]<input type="submit" name="kt_login1" id="kt_login1" value="Login" />[/code] In the page that opens as a result of loggin in: [code]<? session_start();         if (isset($_POST['kt_login1'])):          $_SESSION['kt_login_user'] = $_POST['kt_login_user'];          $_SESSION['kt_name'] = $_POST['kt_name'];         endif; ?> <p>Hello <? echo  $_SESSION['kt_name'] ?> Choose a link to update a part of your records...</p> [/code] In the page that is to contain the update record form: [code] <? session_start();         if (!isset($_SESSION['kt_login_user'])):         $_SESSION['kt_login_user'] = "Anonymous";         $_SESSION['kt_name'] = $_POST['kt_name'];         $_SESSION['kt_welcome'] = $_POST['kt_welcome']; endif; ?> <p>Hello <? echo  $_SESSION['kt_name'] ?> Yada yadda...</p> <?php $sql = "SELECT 'welcome' FROM `users` WHERE `id` = $kt_login_user"; $qry = mysql_query($sql); if(@mysql_num_rows($qry) > 0) { while($r = mysql_fetch_array($qry)) { $kt_welcome = $r[1]; } } else { $kt_welcome = "My default text"; } ?> <textarea name="welcome" cols="80" rows="20"><?php echo $_SESSION['kt_welcome']; ?></textarea> <?php mysql_close(); ?> [/code] I have created 2 users, one with content in the welcome field of their record and the other with a blank welcome field in the welcome field of their record. What is happening at the moment is 1 - The "echo $_SESSION['kt_name" is returning the name of the logged in user (as expected) 2 - the only thing that is being returned in the textarea is My default text. The contents of the user with pre-existing data in his welcome field is not being returned in spite of being logged in. I am coming to honestly believe that PHP was developed to drive me nuts. I would appreciate some direction here. Many thanks in advance.
  24. Being new to dynamic sites this message has thrown me: (working in DWMX 2004 and php/mysql) [b]testing server specified for this site does not map to the [a href=\"http://mysite.....\" target=\"_blank\"]http://mysite.....[/a]. MMHTTP.php URL[/b] Username, password etc. are all correct. The site communicates with the Db I can post entries into the Db from the website, query the site but cannot see the tables from within DW's Applications panel under Databases. It just shows None. Any help is appreciated
  25. Thanks, I had found those extra ";" but their removal didn't make any difference with respect to the outcome.
×
×
  • 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.