
Mavent
Members-
Posts
41 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Mavent's Achievements

Member (2/5)
0
Reputation
-
Posting using database information instead of a form
Mavent replied to Mavent's topic in PHP Coding Help
Ah, that was my second guess. My first guess was to try something like: $_POST['text'] = 'another value'; but it didn't seem to work the way I thought it would. Thanks guys! -
Normally I'd post example code, but I haven't even gotten that far on this. Sorry. I have to send information to a third party in the form of a Post. What I need to know is: can I grab information from a database, then Post it? I know Post automatically sends the content of a form, but can I Post without a form, just using information already stored in a database? Thanks in advance!
-
I could have SWORN that I tried it that way initially, but obviously I didn't, because the second I changed it to '$user' it worked perfectly. Thanks Pikachu2000!
-
This works: $result = mysql_query("SELECT * FROM mydatabase WHERE username = 'billybob'"); This does not: $user = "billybob" $result = mysql_query("SELECT * FROM mydatabase WHERE username = $user"); Shouldn't these be identical? If I echo $user, I get, of course, "billybob", so does anyone know why the variable isn't working in the query itself?
-
Hello all; I have a client that has a members area. He asked me to password protect it, which I did simply by assigning one static password. Now he wants a full username/login system where the member can set their own password, which I have never done before. I assume I'd just set up a Table with three fields, (one for name, one for password, one for the type of access they have) then check against it for access, but experience has taught me that whenever something seems simple, it's actually very complex. Do any of you know of any good premade templates for this kind of thing? Ideally it'd be session-based (obviously). I found one system here: http://frozenade.wordpress.com/2007/11/24/how-to-create-login-page-in-php-and-mysql-with-session/ but it's several years old, and the misspellings in the comments tend to scare me away a bit. Thanks for any help you might be able to provide.
-
Here's the site: http://www.secretauctions.com/thank_atv_cb754.php# (If anyone wants to see how the problem is occurring. The Username and Password shown on the page are functional.) Here's the problem: Whenever anyone tries to click to the second page of results, the Session fails. Here's a short version of the code: <?php $username = "user493d"; $password = "w7atv"; session_start(); $my_array=array($username, $password); $_SESSION['login']=$my_array; if ($_SESSION['login'][0]=="user493d" && $_SESSION['login'][1]=="w7atv") include("atv_list.php"); else include("sorry1.php"); ?> This works GREAT on the initial log-in. But the moment anyone tries to go to the second page of results, the Error state trips, and they get the "sorry" page. This isn't supposed to happen. This is my first foray into Sessions, so I'm certain there's something I'm not understanding, but shouldn't the above code store the username/password, then use it to verify page reloads? Can anyone tell me why it's allowing the Fail state to trip, when the initial test succeeds? Or am I doing the whole thing wrong?
-
I have a bit of code that's supposed to verify the referring page. If it's processlogin.php, then it allows access. Otherwise, it fails. This works: <?php $ref = $_SERVER['PHP_SELF']; if ($ref != '/processlogin.php') header('Location: sorry1.php'); ?> However, when I try and show more data on the page, it fails on Reload. At first I thought it was because the page is seeing itself as an invalid Referrer. So, I added the page itself as a valid referrer, as seen below. <?php $ref = $_SERVER['PHP_SELF']; if (($ref != '/processlogin.php') || ($ref != '/atv_list.php')) header('Location: sorry1.php'); ?> The problem is that now NOTHING works the way I think it should. Whereas if ($ref != '/processlogin.php') worked just fine when it was by itself, now it throws the Fail state. However, the page can now be reloaded, which doesn't make much sense to me. Next I attempted the following: <?php $ref = $_SERVER['PHP_SELF']; if ($ref != '/processlogin.php' || $ref != '/atv_list.php') header('Location: sorry1.php'); ?> Which didn't work either. So I thought that MAYBE it's reprocessing through processlogin.php, and the Variables in the URL were causing the problem. So, I tried this: <?php $ref = $_SERVER['PHP_SELF']; if (strstr($ref,'/processlogin.php')) {header('Location: sorry1.php'); } ?> And again it doesn't work. Anyone know where I went so horribly, horribly wrong?
-
When you say "back on the form", what do you mean, exactly? Do you mean "if the login fails, put the information back into the form"? That's easy enough. In fact, it's almost trivial. Remember that you already HAVE the information- the user gave it to you before they hit Submit. If you're using POST, all you have to do is ask for the information back. For example: $username = $_POST['username']; $password = $_POST['password']; assuming that you named the username and password fields "username" and "password". All you have to do is set the contents of the fields to $username and $password. I hope that helps...
-
It's not the first time that my code has defied the laws of the universe. EDIT: As it turns out, it was that laziest of errors on my part, "not refreshing the cache". I shall now hang my head in shame and contemplate seppeku.
-
I rewrote it like so: $result = mysql_query(" SELECT * FROM auctions WHERE type='Cars' AND (name LIKE '%".$searchterm."%' OR Address LIKE '%".$searchterm."%' OR city LIKE '%".$searchterm."%' OR phone LIKE '%".$searchterm."%' OR zip LIKE '%".$searchterm."%' OR website LIKE '%".$searchterm."%' OR state like '%".$searchterm."%') "); But of course, this being me, it's still doing the exact same thing as before: returning ALL types. Clearly there's something I'm not grasping: doesn't the "WHERE type='Cars', outside of the Parens, force the query to assume Type as a per-requisit to the results within the parens? Thanks!
-
Ah. Is that because of the recursive searchterm instances? I'm trying to pound the concepts into my head- is it conceptually the same thing as writing "WHERE type='y' AND name LIKE 'z' OR type='y' AND name LIKE 'z' OR type='y' AND name LIKE 'z'"? In other words, the type has to be set for each Or statement? I'm trying to wrap my head around the concepts so that one day I shall return, a .php Jedi Master! Thanks Pika!
-
I'm building a query that searches by database and returns matching (or almost matching) terms. That part isn't the problem- I have it up and working. The problem is that I'm trying to narrow down the search results, and it's not working. Here's the query that works: $result = mysql_query("SELECT * FROM auctions WHERE name LIKE '%".$searchterm."%' OR Address LIKE '%".$searchterm."%' OR state like '%".$searchterm."%'"); Here's the query that DOESN'T works: $result = mysql_query("SELECT * FROM auctions WHERE type='Cars' AND name LIKE '%".$searchterm."%' OR Address LIKE '%".$searchterm."%' OR state like '%".$searchterm."%'"); What I'm trying to do is say "give me all the results from type:Cars. Instead, it ignores the WHERE type='Cars' statement, and returns results for all types. It frustrates me because I use the same exact query in a thousand other places, and it works everywhere else. For example: $sql = "SELECT * FROM auctions WHERE type='Boats' AND state='$v4' ORDER BY $v1 $v2"; works just fine. I'm not exactly an expert on any of this, but I can see no logical reason why this works, but the Search code doesn't. They appear in all ways identical, at least as far as query structure goes. Can anyone spot where I screwed up? Thanks! Kyle
-
EDIT: I'm beginning to think that there's a different problem at play here. It's still not ordering correctly, and my guess is that the person who did the data entry copied something in there that's not technically "white space." I think Trim was working as advertised all along, but whatever is in there invisibly is what's screwing up my Query. Originally I was going to post a link to the problem page, but then I realized I'd have fixed it manually before anyone could check it out. Thanks again!
-
See, this is why I love you guys. Oh, and just to clarify: sometimes I forget to explain all the steps that got me from Point "A" to... still at Point "A". In regards to assigning the value, doesn't the second code group do that? In other words, in this code: $Tname = ($row['Name']); echo "Blah blah blah" . trim($Tname); Isn't the Trimmed results inherently implied? trim($Tname) should return the Trimmed results, no? (And to clarify some more: I realize that it's only supposed to remove the white space from the beginning and the end. That's what I need it to do- The results are currently coming back NOT in alphabetical order, because some of them have spaces at the beginning of the string.) In any event, you guys supplied me with three ways to fix my current problem. Thank you very much!