-
Posts
1,008 -
Joined
-
Last visited
Posts posted by spiderwell
-
-
check the users in your phpmyadmin, the error is saying bad password?
also the echoed error is missing the e off the end of the username?
-
good to learn this
thanks
-
how often does a menu change on a website? , is it really necessary to keep it in the database?, thats one extra db call on every page you dont really need
i use this as a common included file for a navigation on many sites i write/have written, obviously you would adapt the output to your needs:
$navarray['Logout'] = 'login.php?action=logout'; $navarray['View Exhibitions'] = 'exhibitions.php'; $navarray['My Sales'] = 'mysales.php'; $navarray['View Images'] = 'images.php'; $navarray['Consigned Images'] = 'consigned.php'; $navstring = "<div class=\"shadetabs\"><ul>"; foreach ($navarray as $key => $value) { $navstring .= "<li"; if (strpos($_SERVER['PHP_SELF'], $value)) $navstring .= " class='selected'"; $navstring .= ">\r"; $navstring .= "<a href='" . $value . "'>"; $navstring .= $key; $navstring .= "</a>\r"; $navstring .= "</li>\r"; } $navstring .= $outputstr; $navstring .= "</ul></div>"; echo $navstring;
this out the menu into a <ul> list and those have so many css interpretations they can look like anything
-
if you want to use the id from a row that you just inserted, you can call it back using mysql_insert_id()
<?php session_start(); if (isset($_SESSION['id'])) { $userid = $_SESSION['id']; $username = $_SESSION['username']; $fname = $_POST['firstname']; $lname = $_POST['lastname']; $telephone = $_POST['telephone']; $city = $_POST['city']; $state = $_POST['state']; $itemname = $_POST['product_name']; $price = $_POST['price']; $details = $_POST['details']; $category = $_POST['category']; $subcategory = $_POST['subcategory']; $product_id = $_POST['product_id']; $customer_id = $_POST['customer_id']; $date_sold = $_POST['date_sold']; $sqlinsert = "INSERT INTO customers (id,firstname,lastname,telephone,city,state,product_name,price,details) VALUES('','$fname','$lname', '$telephone','$city','$state','$itemname','$price','$details')"; $enterquery = mysql_query($sqlinsert) or die(mysql_error()); $customer_id= mysql_insert_id(); $sqlinsert2 = "INSERT INTO products (id,product_name,price,details,category,subcategory) VALUES('','$itemname','$price','$details','$category','$subcategory')"; $enterquery2 = mysql_query($sqlinsert2) or die(mysql_error()); $product_id = mysql_insert_id(); $sqlinsert3 = "INSERT INTO sales (id,product_id, customer_id, date_sold) VALUES('','$product_id','$customer_id','$date_sold')"; $enterquery3 = mysql_query($sqlinsert3) or die(mysql_error()); } ?>
-
Splitting up HTML and PHP doesn't mean you can't show any error's, you can just pass them:
$errors = array(); include('page.html');
In your page.html you could then have:
<?php if(sizeof($errors)): ?> <ul> <li><?php print $errors[0]; ?></li> </ul> <?php endif; ?>
Show us your entire script and I'll show you how you can refactor it for reusability.
dont you need to have .php extension though or the php wont execute?
-
<?php $query2 = "SELECT * FROM psychofarm_gen WHERE `id`!=".$randomNumber; $result2 = mysql_query($query2); while($row = mysql_fetch_array($result2)) { $wrong_answer[] = $row['name']; } ?>
you dont need the $i counter, it will automatically set the key value when omitted, unless you want to explicitly set it of course
-
query2 = "SELECT * FROM psychofarm_gen WHERE `id`!=".$randomNumber LIMIT 3;";
is that what you are after?
-
... and sorry for the mispelling of your name Maq.
Heh, no problem. Happens a lot actually.
i've seen it twice and only joined last week lol.
welcome to the forum too jj
-
really i guess its down to personal preference, if you do a redirect, I am guessing you will need to send variables to that redirect, I can't see the point in that personally.
you could make a function for the payment method or use an include file to keep the code seperate.
I guess it boils down to if that payment process is a code you need to use on other pages or not? if not used anywhere else why not keep it all in the same page. if its used multiple times by different pages, i would put it in its own page in a function/ or in a class.
-
the first line is what i mean by outside i.e. its not inside quotes, as you can out put variables inline "something $variable ".
echo " alot of text here and then treasure holdings: ".round($row['team_treasure'],2)." and some more text here"; //works echo " alot of text here and then treasure holdings:round($row['team_treasure'],2) and some more text here"; //wont work
-
i made a cms system which stores title,meta keywords & page content all in a db, but its much the same result really. if i really wanted to be clever, i should build a publish button to 'write' the final page in html, so the db isnt hit on every page request, but most the sites i make arent as popular as facebook so its not really an issue
-
then do it outside of them
this should work, he says without checking it
echo round($row[team_treasure],2);
-
yeah i once had to write a website using file scripting as my method of storing everything that was updateable/editable, it was a pain in the backside.
-
While you're at it, there's no need to concatenate the variables into the strings all the time like that. The output from the following is the same as what will be generated by your echoes.
echo "You sent $amount to $member<br />"; } } echo " $amount and $member";
is there a performance difference with doing it this way? i always use the . concatenate method , just because i find it easier to read in notepad++, lol
-
do you want this to be able to send each member the same amount of different amounts?
a form with a dropdown box with members listed with a text input next to it should get you started, however that means you would only be able to send to one member at a time.
a multiselect box would bring issues of only being able to send the same amount to all members.
a form a bit like this would work for one member at a time:
<?php if($_POST) { $amount = $_POST['amount']; $sendtomember = $_POST['memberlist']; //i going to skip some obvious stuff like DB connecting,error trapping etc $balance = $row['field']; // execute query to get amount in DB if($amount <= $balance) { //do querys to send amount to member, and subtract from balance of sender, using $amount and $sendtomember variables } else { echo " you cannot send more than you have"; } } ?> <form method="POST"> <select name="memberlist"> <option>Choose a member</option> <option value="1">johnny</option> <!-- value is ID of user in db --> <option value="2">peter</option> </select> <input type="text" name="amount"> <input type="submit" value="send amount"> </form>
obviously this code wont work, but like you said, it might point you in the right direction
you could be clever and use ajax to add extra rows in the form, if user desired to send to another member, but of course that will involve having more error trapping and multiple querys to DB etc
-
CKEDitor is also a great tool for this, it has many more functions but you can set the toolbar to do just the things you mentioned you
-
damn i keep missing those single quote errors lol
-
if($numrows = '1')
look closer
-
yeah I have always used server side validation for exactly this reason!
-
you need to use the $_SESSION object to store the usrname and/or password
then check for that session existing on each protected page.
I would give an example but i have to go out now, sorry buddy !
-
so no ghosts in the machine after all, shame
-
that script is going to work, but the issue is that the loginreferingtoken.html page isnt protected by a login check, being a plain html document.
what could be done is that you could set a session variable once a user is logged in, and on each page (change extenstions to .php) to check if that session is set, and if not redirect away.
-
<tr><td>First Name:</td><td><input type="text" name="first" value="<?php echo $row['first'] ?>">
try replacing the table row entries with something like above where $row is your recordset and ['first'] is the appropriate column name from db
-
you would use reg exp to do it, but I am not very good at them.
someone will be along in a minute.
Register Page for both Admin/Users
in PHP Coding Help
Posted
in sites i have made in the past, i have an auto edit form that pre populates the users info, and depending on if that user is an admin or just a normal user, the user group option is hidden or in a drop down.
i.e. an ordinary user will not get the option to change group from user to admin, but the same form viewed by admin will have an extra field with these options.
in fact the same form also works for adding new users via the cms backend or as a register form on the front end.