
webmaster1
Members-
Posts
607 -
Joined
-
Last visited
Never
Everything posted by webmaster1
-
Loading images to mySQL using a PHP form?
webmaster1 replied to webmaster1's topic in PHP Coding Help
So I basically load the images to a folder first and just post the path via my form into mySQL? When outputting the data do I use a string of some sort to combine a little html with the outputted path? Can mySQL/PHP ouput code into a web page that will be read as regualr code by the browser or do I have to use some sort of a loop? I don't even know what I'm talking about. -
Loading images to mySQL using a PHP form?
webmaster1 replied to webmaster1's topic in PHP Coding Help
Thanks cunoodle2! Will attempt to implement this shortly and get back to you. -
Loading images to mySQL using a PHP form?
webmaster1 replied to webmaster1's topic in PHP Coding Help
I'm hoping that I can post all to the one database via PHP like so: <form action="inputdata.php" method="post"> <fieldset> <ol> <li> <label for="make">Make:</label> <input type="text" name="make" id="make" class="text"> </li> <li> <label for="model">Model:</label> <input type="text" name="model" id="model" class="text"> </li> <li> <label for="price">Price:</label> <input type="text" name="price" id="price" class="text"> </li> <li> <label for="engine">Engine:</label> <input type="text" name="engine" id="engine" class="text"> </li> <li> <label for="image1">Image 1:</label> <input type="file" name="image1" id="image1"> </li> <li> <input type="submit" class="submit"> </li> </ol> </fieldset> </form> <!--INPUT FORM ENDS HERE--> -
Hi Freaks! I require a form to post an image (amongst other text values) to a mySQL database which I'll later output in another page. I've read somewhere that some web hosting providers won't allow this. Is this true and should I be going about this another way? While I'm badgering you all does anyone know what type my image field should be in mySQL (e.g. VARCHAR etc.)?
-
Nice, I like the flag logo (I'm Irish and living in Ireland btw) and the black gloss is very web2.0ish! I'm going to invest some time in Joomla then. I'm sure it will be quicker than building a cms and product gallery from scratch in PHP. I've found a few relevant tempates here: http://forum.joomla.org/viewtopic.php?t=2053 I don't want to give it full control because I've already built quite a bit of the site.
-
I installed JOOMLA via my CPANEL but I instantly took a disliking to it. :-\ Is it true that I can't apply JOOMLA to just one of my pages and that it needs to be applied to my entire site? From a design perspective it seems restrictive. I can always spot a site that uses Joomla when I see it.
-
PHP hacking, web crawling and security...
webmaster1 replied to webmaster1's topic in PHP Coding Help
I never considered myself a paranoid individual until I began looking into PHP. -
Hi Freaks, I'm need to build a basic product catalog (automobiles) that does not require a shopping cart are any additional functionality aside from viewing it and possibly filtering the results (not an essential). I've searched for a few free open source solutions but I can't make heads or tails out of which ones might suit me best or which ones I actually require. Can anyone reccomend a suitable free software solution? Would it be better just attempting to build this myself from sratch? The client will be updating the catalog themselves so it needs to have a user freindly update/edit section.
-
PHP hacking, web crawling and security...
webmaster1 replied to webmaster1's topic in PHP Coding Help
Thanks for sharing your insight. I'm using an intermediary PHP form to validate a password form so since there's no SQL involved I should be set. Thanks. -
I found it! After hours of searching and trying different scripts I finally found a neat method to adding a rollover effect on a submit button that uses the INPUT type="image" approach. It uses an external *.js file. http://www.dynamicdrive.com/dynamicindex15/domroll2.htm SOLVED!
-
Hi Freaks, A freind of mine once used crawling to download/view (not sure) the contents of another site. Firstly how do I prevent this from happening to page and secondly how can I go about doing it (to check my own site). I'm concerned that my if my php forms are accessed/downloaded/viewed that any would-be hacker will be able to view my passwords and begin to mess with my site.
-
Great link Flyhoney! I've rebuilt it as follows: passwordform.php <!--PASSWORD FORM BEGINS HERE--> <form action="valid.php" method="post"> <fieldset> <ol> <li> <label for="username">Username:</label> <input type="text" name="username" id="username"> </li> <li> <label for="password">Password:</label> <input type="password" name="password" id="password"> </li> <li> <input type="image" src="images/loginbutton1.jpg" alt="Click to Sign In"> </li> </ol> </fieldset> </form> <!--PASSWORD FORM ENDS HERE--> passwordform.css /* passwordform */ fieldset { position:relative; left:280px; top:30px; margin: 0 0 0 0; padding: 0; border-style:none; } fieldset ol { padding-top:0x; list-style: none; } fieldset li { padding-bottom:0px; } fieldset.submit { border-style: none; } label { float: left; width:60px; margin-right: 10px; font-family:Trebuchet MS, Arial; font-size:12px; } I still can't work out how to tie the button mouseover / images swap effect in without effecting my PHP. This is probably a CSS related (and more of an indirect PHP) question though. I geuss I can leave it as a static image. :'(
-
Roadblock, I'm using an image (w/rollover effect) as a button instead of a regular submit button: <TABLE> <TR> <TD><label style="font-family:Trebuchet MS, Arial; font-size:12px;">Username:</label></TD> <TD><input name="username" type="text" class="text"></TD> </TR> <TR> <TD><label style="font-family:Trebuchet MS, Arial; font-size:12px;">Password:</label></TD> <TD><input name="password" type="password" class="text"></TD> </TR> <TR> <TD></TD> <TD><A HREF="#null" onMouseOver="imgOn('img1')" onMouseOut="imgOff('img1')"> <IMG name="img1" BORDER=0 width="70" height="20" SRC="images/loginbutton1.jpg" alt="Click to Sign In"> </A> </TD> </TR> </TABLE> How do I set my image as a button to cause my form to post? I'm not quite sure where to insert my form tags in relation to the table either. Here's the javascript that controls the mouseover effect: <SCRIPT LANGUAGE = "JavaScript"> <!-- if (document.images) { img1on = new Image(); // The onmouseover image img1on.src = "images/loginbutton2.jpg"; img1off = new Image(); // The normally seen image img1off.src = "images/loginbutton1.jpg"; } //This function changes the image when over. function imgOn(imgName) { if (document.images) { document[imgName].src = eval(imgName + "on.src"); } } //This function changes the image back when off. function imgOff(imgName) { if (document.images) { document[imgName].src = eval(imgName + "off.src"); } } // --> </SCRIPT>
-
Thanks flyhoney. Thats seems linear enough. I'm trying it out now and will post back if I reach a roadblock.
-
If you follow this to the letter you'll have a nice little form mail. I'll be online for a while if you want to try it out and get back to me with any questions.
-
Here's a form mail I stitched together from various tutorials. Hope you like! form.html <html> <head></head> <body> <table> <form action="process-form.php" ... method="post"> <tr> <td>Name</td> <td><input type="text" id="name" name="name" /></td> </tr> <tr> <td>Email address:</td> <td><input type="text" id="email" name="email" /></td> </tr> <tr> <td>Recipient:</td> <td> <select id="recipient" name="recipient"> <option value="a">someone</option> <option value="b">someoneelse</option> </select> </td> </tr> <tr> <td>Subject:</td> <td><input type="text" id="topic" name="topic" /></td> </tr> <tr> <td valign="top">Your comments:</td> <td><textarea id="comments" name="comments" rows="5" cols="30"></textarea></td> </tr> <tr> <td></td> <td><button type="submit">Send</button></td> </tr> </form> </table> </body> </html> process-form.php <?php // Pick up the form data and assign it to variables $name = $_POST['name']; $email = $_POST['email']; //$recipient = $_POST['recipient']; // Conceal mail, switch and case switch(@$_POST['recipient']) { case 'a': $recipient = '[email protected]'; break; case 'b': $recipient = '[email protected]'; break; default: $recipient = '[email protected]'; // if they don't send one of the valid options } $topic = $_POST['topic']; $comments = $_POST['comments']; $now_datetime = date('Y-m-d h:i:s'); $ipaddress = getenv('REMOTE_ADDR'); // Build the email //$to = '[email protected]'; $to = "$recipient"; $subject = "New message: $topic"; $message = "$name wrote:\n\n$comments\n\nMessage sent: $now_datetime\n\nI.P. Address: $ipaddress"; $headers = "From: $email"; // Send the mail using PHPs mail() function mail($to, $subject, $message, $headers); //write the information back to database include("dbinfo.inc.php"); $now_datetime = date('Y-m-d h:i:s'); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO yourtablename VALUES ('','$now_datetime','$ipaddress','$name','$email','$recipient','$topic','$comments')"; mysql_query($query); mysql_close(); // Redirect header("Location: success.html"); dbinfo.inc.php <? $username="yourusername"; $password="yourpassword"; $database="yourdatabase"; ?> success.html <html> <head></head> <body> <p>Your information has been sent!</p> </body> </html> The drop down allows users to select from a recipient list. Recipient recieves Sender's Email, Name, Message, Date/Time and IP Address. A copy of the message is also saved to a database. The DATABASE structure is as follows: index | mediumint(9) | Null No | autoincrement time| datetime| NULL Yes | Default NULL ipaddress | mediumint(9) | Null No name | varchar(100) | Null No email| varchar(255) | Null No recipient | varchar(255) | Null No topic | varchar(255) | Null No comments | text | Null No
-
Hi Freaks! I have the following page layout: The areas in red are php related sections. The PASSWORD FORM (regular form that posts to a php page) links to a private page and the UPDATED CONTENT will be pulled into the page from database using PHP. Should I just insert the PHP in between my HTML code or should I use the include function (which I have no clue of)? Can I do more than one thing with PHP in the same page like I'm trying and if so what prevents the code blocks from conflicting with each other? I'm worried that the PHP will mess the layout of my site.
-
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
Premiso: FYI Minor typo on line two of your privatepage block; the word 'session' is spelt incorrectly. -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
Solved! Premiso: You are a God! Your code is accurate, concise and complete! Thanks for not only figuring out the solution but also for figuring out what it was I was trying to ask! This site rocks. Hopefully in a few months I'll be in a position to answer a few of the threads here. I'll be nagging you all until then. (You're a God too Thorpe! ) -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
My only concern with Premiso's method is that the URL of the private page can be accessed by typing it in to the address bar. -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
I've attempted Thorpes method but I keep on getting the following error: I've used the following code: page.php <html> <head></head> <body> <form action="login.php" method="post"> <input type="text" name="username"> <input type="password" name="password"> <input type="submit"> </form> </body> </html> login.php <?php include("dbinfo.inc.php"); if (isset($_POST['username']) && isset($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $userpass = mysql_real_escape_string($_POST['password']); $sql = "SELECT username FROM users WHERE username = '$username' && password = MD5('$password')"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { session_start(); $_SESSION['logged'] = true; header("location: private.php"); } else { header("location: invalid.php"); } } } ?> dbinfo.inc.php <? $username="XXX"; $password="XXX"; $database="XXX"; ?> private.php <?php session_start(); if (isset($_SESSION['logged'])) { // private stuff goes here. } else { echo "Sorry, you need to be logged in to view this page"; } ?> Can anybody spot where I've gone wrong? It occurs when I click the submit button on my form. My database is already created. I know I'm close to completing this but I can't seem to get passed this error. -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
Right, I'm back. Thanks for the input. I'll post my code as soon as its completed. (obviously not for any of you brainchilds but for any fellow newbs that stumble across this thread via a search engine.) -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
So far I've gotten Premiso's to work (thank you so much): page.html <html> <head></head> <body> <form action="valid.php" method="post"> <input type="text" name="username"> <input type="password" name="password"> <input type="submit"> </form> </body> </html> valid.php <?php $valid_username = "admin"; $valid_password = "password"; $username = isset($_POST['username'])?$_POST['username']:""; $password = isset($_POST['password'])?$_POST['password']:""; if ($username == $valid_username && $password == $valid_password) { header("Location: privatepage.html"); }else { header("Location: index.html"); } ?> I'm looking into Thorpes method as soon as I finish creating the database. I just have a few questions: Is my password method less secure if I don't use SQL? Can I just 'include' the form as a header in my html page or must any page I use the form with have the .php extension? (e.g. index.php) Is it possible use an image as button (with a javascript rollover effect) with the php code or should I not even bother googling it? Sorry for badgering but I'm sure this thread will help round up this topic for other newbies like me. -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
I was hoping to clarify a few basics based on the code provided by Premiso. To try out the code I have a page.html with the following code: <html> <head></head> <body> <input type="text" name="username"> <input type="password" name="password"> <input type="button" name="login" value="login"> </body> </html> How do I link the form to valid.php? Sorry for being such a newb, I know these are probably very basic questions but I apreciate the help. -
[SOLVED] Password authentication and then redirect?
webmaster1 replied to webmaster1's topic in PHP Coding Help
Thanks so much Premiso; I'm checking this now and will get back to you in a few minutes!