-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
Most likely for subdomains there is a folder created under the root directory.
So for the path put: /foo/
Domain: .foo.com
-
When it comes to SQL queries, the exception is made.
The query seems find, just put the or die statement like you did for the other one.
-
Nice mistake.
-
Congratulations for making the 4th most replied topic in the PHP Help forum. lol
-
$hour = date("h", strtotime("-5 hours")); echo $hour;
My results: 07
Current time where I am is 12pm, so 07 would be correct.
-
$pattern = "/\[wiki\](.*?)\[\/wiki\]/is"; $replace = "<a href=\"http://en.wikipedia.org/wiki/$1\">$1</a>"; $string = "[wiki]Apple[/wiki]"; echo preg_replace($pattern,$replace,$string);
You could try...
-
Start off easy, then continue to excel in harder questions.
Correct delimiters to open PHP scripting...
Valid / invalid variables? ($blah, $4, $blah4, $blah-4, etc...)
Strings, yes.
Math, incrementing and decrementing values.
Connecting strings
Echo / Print
Include / Require
Then move forth more difficult tasks, multi-dimensional arrays, MySQL, etc... logic....
-
./ = same directory
/ = main root directory
../ = parent directory
-
$fwrite should be fwrite
Also you have an extra semi-colon at the end of the $fp variable.
-
$sel = ($myrow['autoplay'] == '1') ? " SELECTED" : ""; echo "<select name=\"autoplay\">\n"; echo "<option value=\"0\">No</option>\n"; echo "<option value=\"1\"".$sel.">Yes</option>\n"; echo "</select>\n";
-
Capasha? You mean Captcha?
-
if(isset($staffid)){ echo "Staff ID is set"; }else { echo "Staff ID was not provided!"; }
-
You can use some regex to complete this task.
-
Correct.
According to your form once you submit it, your URL will look something like this:
http://website.tld/staffMenu?staffid=x&submit=Submit
Using the $_GET method, you will define the two variables as:
$staffid = $_GET['staffid']; $submit = $_GET['submit'];
If you want to use this for continuous use you're going to want to use sessions or cookies to pass the data throughout any other pages that you wouldn't want the user having to type the Staff ID again.
-
You can create a function I suppose. I do this with my website.
function uname($id){ $sql = "SELECT username FROM `users` WHERE `id`='".mysql_real_escape_string($id)."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ return "Invalid User"; }else { $row = mysql_fetch_assoc($res); return $row['username']; } } echo uname(5);
-
To save some time just use a buffering method.
<?php ob_start(); // your code ob_end_flush(); ?>
-
Lol no.
$usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password']));
-
$passcheck = md5($passcheck);
-
wordwrap and substr.
-
<?php //connect to MySQL $connect = mysql_connect("localhost", "root", "michael") or die("Could not connect to database."); //choose the database mysql_select_db("jostark"); //get data from database $query = mysql_query("SELECT `companyID`,`compName`, `compCity`, `compCountry` FROM `placement` ORDER BY `companyID` ASC") or die(mysql_error()); echo "<select name='placement'>\n"; while ($data = mysql_fetch_array($query, MYSQL_ASSOC)) { $sql = "SELECT * FROM `table` WHERE `companyID`='".$data['companyID']."'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); $sel = ($row['companyID'] == $data['companyID']) ? " SELECTED" : ""; echo "<option value='".$data['companyID']."'6".$sel.">".$data['compName'].", ".$data['compCity'].", ".$data['compCountry']."</option>\n"; } echo "</select>\n"; ?>
edit the $sql variable to fit your query needs
-
Try just doing:
$usercheck = addslashes($_POST['username']); $passcheck = addslashes($_POST['password']);
When a user registers does their password get encrypted?
-
Just remove the line that has $Row2
-
Can you verify the passwords are md5 encrypted?
-
<?php // Connects to your Database include ('Connect.php'); $submit = $_POST['submit']; //Body Settings echo "<center><font color='#AFAFAF' face='verdana' size='1'>"; //If User Is Logged In if (isset($_COOKIE['UserID'])) { //Display Message echo "Sorry, you are already logged in. Click <a href='index.php'>Here[/url] to go back."; //Exit Page exit; } //If Form Is Submitted if ($submit) { // Checks if pass/user exists $_POST['username'] = addslashes($_POST['username']); $usercheck = $_POST['username']; $_POST['password'] = addslashes($_POST['password']); $passcheck = $_POST['password']; $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); $Rows2 = mysql_fetch_array($Result2); if (mysql_num_rows($Result1) == 0) { echo "Invalid Username/password."; exit; } $UserID = $Rows1['ID']; setcookie("UserID", "$UserID", time() + 9999999); echo "You have successfully logged in. <a href='index.php'>Continue</a>"; } //If Form Isn't Submitted else { echo " <form method='POST'> <input type='hidden' name='submit' value='1'> Username <input type=\"text\" name=\"username\" maxlength=\"30\"> Password <input type=\"password\" name=\"password\" maxlength=\"25\"> <input type='submit' value='Sign In' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </form>"; } ?>
mysql_num_rows
Linking multiple database
in PHP Coding Help
Posted
No.
Use separate connections.