wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
You can use sessions with a database if you wish to, rather than having the SESSID being stored in a cookie/url. Or you can use use secure http connect (https), which will encrypt any data being transfered from client to server, or from server to server.
-
The main reason is becuase PHP4 doesnt have the same level of OOP as PHP5 has. For example PHP doesnt support public, private or protected keywords when defining methods/objects with PHP4. I'd recommend you to read the manual for using OOP with PHP4, [url=http://uk.php.net/manual/en/language.oop.php]here[/url]. Also if you are learning. I would strongly suggest you install Apache2.0.x, PHP5.x and MySQL4.x on your local PC/Mac/Laptop. This will allow you to develope and test your PHP scripts locally, offline, rather than using a host.
-
If your are getting that error then either your relative addressing is wrong, or the file your are including doesnt exist.
-
Remove print from this line: fputs($file_write, print($name), "$input_file[0]"); // input the info from form so its just: fputs($file_write, $name, "$input_file[0]"); // input the info from form
-
Topic has been merged. Please do not post now topics for no reason.
-
Need Help With Registration System(Done, but needs expanding)
wildteen88 replied to techiefreak05's topic in PHP Coding Help
To add an email field, find this: [code]<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr>[/code] And add the following after it: [code]<tr><td>Email:</td><td><input type="text" name="email" maxlength="50"></td></tr>[/code] Now find the following: [code]function addNewUser($username, $password){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password')"; return mysql_query($q,$conn); }[/code] And replace with this following: [code]function addNewUser($username, $password, $email){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password', '$email')"; return mysql_query($q,$conn); }[/code] Change this: [code]$_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass);[/code] to this: [code]$_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass, $_POST['email']);[/code] Add the following: [code]/** * Returns true if the email address is already * in use by another user, false otherwise. */ function emailUsed($email){ global $conn; if(!get_magic_quotes_gpc()){ $email = addslashes($email); } $q = "select email from users where email = '$email'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); }[/code] AFTER this: [code]function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "select username from users where username = '$username'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); }[/code] Now add the following: [code]/* Check if email is already in use */ if(emailTaken($_POST['email'])){ $email = $_POST['email']; die("Sorry, the email address (<i>{$email}</i>) provided is already in use"); }[/code] After: [code]/* Check if username is already in use */ if(usernameTaken($_POST['user'])){ $use = $_POST['user']; die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one."); }[/code] That should be about it. Any trouble please post back. -
This is probably a stupid question, please answer?
wildteen88 replied to Emma316's topic in PHP Coding Help
Sorry for the spelling mistakes. Also I did try to explain it as best as I could. Or am I getting my wires crossed here? Also most tutorials now adays take you on a copy 'n' paste session, and dont bother explaining the code. -
Try this: [code=php:0]$string = "blue"; $lines = file('file.txt'); //echo '<pre>' . print_r($lines, true) . '</pre>'; // remove any whitespace chars from the lines if (in_array ($string, str_replace(array("\r", "\n"), '', $lines))) echo "in";[/code]
-
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING
wildteen88 replied to graciehz's topic in PHP Coding Help
I would suggest you use HEREDOC if you have alot of HTML like so: [code=php:0]$menu = <<<HTML <P align="left"> <img name="phone_item_equip_flat" src="phone_item_equip_flat.png" width="110" height="47" border="0" usemap="#m_phone_item_equip_flat" alt=""><map name="m_phone_item_equip_flat"> <area shape="poly" coords="80,27,81,22,84,17,89,14,95,12,101,14,106,17,109,22,110,27,109,33,106,38,101,41,95,43,89,41,84,38,81,33,80,27,80,27" href="javascript:void;" alt="" > <area shape="poly" coords="39,27,40,20,44,15,49,11,55,10,62,11,67,15,71,20,72,27,71,33,67,39,62,42,55,43,49,42,44,39,40,33,39,27,39,27" href="javascript:void;" alt="" > <area shape="poly" coords="-1,27,0,21,4,16,9,13,15,12,21,13,26,16,30,21,31,27,30,34,26,39,21,42,15,43,9,42,4,39,0,34,-1,27,-1,27" href="javascript:void;" alt="" > </map></P> HTML; // dont indend the line above !![/code] -
This is probably a stupid question, please answer?
wildteen88 replied to Emma316's topic in PHP Coding Help
[quote author=Emma316 link=topic=101198.msg400275#msg400275 date=1153381506] So field names have to be in quotes? Ok thanks :) [/quote] Emma ideally they are supposed to be in quotes but not many people do. But the real reason why your query fails was because you are using a mysql keyword for a field name - from MySQL was getting confused when it came uppon the word from. When you place it in backticks - `from` - MySQL then wont get confused and use from as the field name. -
Parse error: parse error, unexpected T_STRING
wildteen88 replied to chaos_ali's topic in PHP Installation and Configuration
Strange nothing wrong with that. Make sure you dont have any whitespace before <?php and ?> -
Session vars disappear when loop is used to assign them
wildteen88 replied to Kingskin's topic in PHP Coding Help
Code looks fine to me, and I cant see nout wrong with it. However i'd suggest you use mysql_fetch_assoc rather than mysq_fetch_array, otherwise you'll get duplicate sessions, one with a numerical key and another with a string key eg: for your userid session, you'll get userid sessions like so: $_SESSION[0] and $_SESSION['userid'] With mysql_fetch_assoc this wont happen. Another suggestion which may not help but chnage this: [code]$_SESSION[$key] = $value;[/code] to: [code]$_SESSION[{$key}] = $value;[/code] Also make sure you have session_start(); as the first line for everypage that use's sessions. -
setting register_globals to on for one website only
wildteen88 replied to brianstorm's topic in PHP Coding Help
Create a new file called .htaccess within the direcotry your shopping cart is stored in and the following to it: [code]php_flag register_globals On[/code] Save the .htaccess file. Your script should now work and register_globals will be on for that script only. -
What's the best way to require a login to access this?
wildteen88 replied to simcoweb's topic in PHP Coding Help
something like this: [code=php:0]<?php session_start(); //IP logger file viewer - set variables include 'config.php'; include 'header.php'; $title = "<center><h4>IP Log File - Unauthorized Access Results</h4></center><p>"; // authenticate the user as the administrator $password = strip_tags(chop($_POST['password'])); if($_GET['logout'] == true) { unset($_SESSION['logged_in']); session_destroy(); } if($password == $admin_password) { // session_register("logged_in"); -- this is not needed $_SESSION['logged_in'] = true; } if($_SESSION['logged_in'] == true) { echo 'Logged in!<br><a href="' . $_SERVER['PHP_SELF'] . '?logout=true">logout</a>'; // if successful it will connect to the database and display the info mysql_connect('$dbhost', '$dbuser', '$dbpass') or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); echo $title . "<p>\n"; print "<table align='center' width='600' border='0'><tr><td>"; // loop through array and print each line $query = "SELECT * FROM iplog"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['ip']. " - ". $row['date']; echo "<br />"; } echo <<<HTML </tr></td><tr><td><p><font face='Verdana' size='2'><strong>When you are through viewing these results click below to download an Excel CSV file or to erase the entries from the database.</strong></font><p></td></tr></table> <table width="400" align="center"> <tr><td width="200" align="center"> <form action="closefile.php" method="POST"> <input type="submit" name="submit" value="Close File"> </form> </td><td> <form action="download.php" method="POST"> <input type="submit" name"download" value="Download Excel File"> </form> </td></tr></table> HTML; } else { echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <input type="text" name="password"> <input type="submit" name="login" value="Login"> </form>'; } ?>[/code] -
You cant use that smtp server with mail then. If you want to use that smtp server I think you'll have to use imap which allows you to login to mail servers.
-
You are missing closing } or ) if you are getting that error. Go through you code making sure your } and ) pair up.
-
Does the smtp server you are using require you to login? If it does you cannot use this SMTP Server as mail doesnt support authentication requests - loggin.
-
You have a missing ; and } after this: [code=php:0]if (!isset($_COOKIE['ID_my_site'])) { header('./logout.php')[/code] it should be: [code=php:0]if (!isset($_COOKIE['ID_my_site'])) { header('./logout.php'); // missing } // missing[/code]
-
To use mail you'll need to point it to an actual SMTP server. If you dont have an SMTP installed on your local machine it will not send an email. See if you can find a public SMTP server which does require authentication in order to send an email, as mail does support this. You shouldn't have to change the port number as SMTP servers run on port 25
-
Rather than using die or exit, Do something like this: [code=php:0]if(isset($_POST['submit'])) { // do email stuff here } else { // display form here }[/code]
-
Function seems executed twice when called only once.
wildteen88 replied to Jordi_E's topic in PHP Coding Help
Change this: [code]return ($this->num_rows() == 1); [/code] to this: [code]return (($this->num_rows() == 1) ? true : false);[/code] The change this: [code]if (!$this->BOX_exists( $BOX_id ))[/code] to this: [code]if ($this->BOX_exists( $BOX_id ) === true)[/code] -
how can i make more then one table in one install file?
wildteen88 replied to scheols's topic in PHP Coding Help
Create an array of all the tables needed to be installed. The use foreach loop to create the table eg: [code=php:0] $tables = array(); //table 1 $tables[] = "CREATE TABLE table1 ( -- table1 fields here );"; // table 2 $tables[] = "CREATE TABLE table2 ( -- table2 fields here );"; // connect to db here // now loop through our table array to create our tables: foreach($tables as $table => $query) { // perform our query mysql_query($queryl) or die(mysql_error()); }[/code] Thats is basically how got about create more than one table automatically. -
You only to use AND in a query you are comparing somthing to something else, such as within a WHERE clause
-
Not a bad site. Like the overall design, however I feel as though your menu needs a bit more work put into it as at the mement its a little bland. Also in few pages you have submit buttons that has the defualt "Submit Query" text. You should change it something else, suhc for the PR make change the button text to "Get Page Rank" Also you have a contact page, which has your email addy in it. You should make a contact form for visitors to contact you rather than just provide an email addy. If you want to send an email with PHP use the mail function. Well that my 2cents
-
Setting Up PHP 5.1.4 with mySql 5.0.22
wildteen88 replied to Michael's topic in PHP Installation and Configuration
Michael, have a read of [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this thread[/url]. Also how did you install PHP? Did you use an installer? or with zipped binaries?