Jump to content

ptex

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ptex's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok let me ask this if this code [code]<?php // Define your username and password $username = ""; $password = ""; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">     <p><label for="txtUsername">Username:</label>     <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>     <p><label for="txtpassword">Password:</label>     <br /><input type="password" title="Enter your password" name="txtPassword" /></p>     <p><input type="submit" name="Submit" value="Login" /></p> </form> <?php } else { ?> <p>put what you want to see after your password had been checked here</p> <?php } ?> [/code] and this code [code] <?php include("includes/databaseconnect.php");//include the file that connects to the database if(!empty($title)) {//if the title is not empty, than do this function $title = addslashes($title); $user = addslashes($user); $message = addslashes($message); $date = date("F j, Y");//set up the date format $date2 = mktime(); $sql = "INSERT INTO mynews (id, title, user, message, date) VALUES ('NULL', '$title','$user','$message','$date')";//Insert all of your information into the mynews table in your database $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); echo "Database Updated."; } else {//However, if the title variable is empty, than do this function ?> <form name="news" method="post" action="<?php echo $PHP_SELF; ?>"> <p>Please fill out all of the following fields:</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="117"><font size="1">Topic/Title*: </font> </td> <td width="577"> <font size="1"> <input type="text" name="title" size="50"> </font> </td> </tr> <tr> <td width="117"><font size="1">Username*:</font></td> <td width="577"> <font size="1"> <input type="text" name="user" size="50"> </font> </td> </tr> <tr> <td width="117"><font size="1">Message*:</font></td> <td width="577"> <font size="1"> <textarea name="message" rows=10 cols=43></textarea> </font> </td> </tr> </table> <p> <font size="1"> <input type="submit" name="Submit" value="Submit"></font> </p> </form> <?php }//end this function ?> [/code] Both work how can I make them work together?
  2. Right line 5 I took out the password for now. Thats were I put the usernames and passwords for example I could put for user name "testuser" then for password "testpassword" and when you went to the page and was prompted if the UN and PW matched it will let you get to the form part of the code which it will. My issue is after all that when I try to submit my form nothing happens.
  3. For the password part or the submit form part? On the form part no pass word is needed but to get to the form you need a password.
  4. What I am trying to do is password protec a page that a user adds info to which goes to a table and updates that users area of a web site. The password part works good and the form used to input date works well but it all falls apart when I put the two parts together. I can log in with a user name and password but when I submit my form it will not update the database??? Can any one see why this happens and thanks in advance. ??? [code]<?php // Define your username and password $username = ""; $password = ""; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">     <p><label for="txtUsername">Username:</label>     <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>     <p><label for="txtpassword">Password:</label>     <br /><input type="password" title="Enter your password" name="txtPassword" /></p>     <p><input type="submit" name="Submit" value="Login" /></p> </form> <?php } else { ?> <?php include("includes/databaseconnect.php");//include the file that connects to the database if(!empty($title)) {//if the title is not empty, than do this function $title = addslashes($title); $user = addslashes($user); $message = addslashes($message); $date = date("F j, Y");//set up the date format $date2 = mktime(); $sql = "INSERT INTO mynews (id, title, user, message, date) VALUES ('NULL', '$title','$user','$message','$date')";//Insert all of your information into the mynews table in your database $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); echo "Database Updated."; } else {//However, if the title variable is empty, than do this function ?> <form name="news" method="post" action="<?php echo $PHP_SELF; ?>"> <p>Please fill out all of the following fields:</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="117"><font size="1">Topic/Title*: </font> </td> <td width="577"> <font size="1"> <input type="text" name="title" size="50"> </font> </td> </tr> <tr> <td width="117"><font size="1">Username*:</font></td> <td width="577"> <font size="1"> <input type="text" name="user" size="50"> </font> </td> </tr> <tr> <td width="117"><font size="1">Message*:</font></td> <td width="577"> <font size="1"> <textarea name="message" rows=10 cols=43></textarea> </font> </td> </tr> </table> <p> <font size="1"> <input type="submit" name="Submit" value="Submit"></font> </p> </form> <?php }//end this function ?> <?php } ?> [/code]
  5. [!--quoteo(post=377051:date=May 25 2006, 11:34 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 25 2006, 11:34 AM) [snapback]377051[/snapback][/div][div class=\'quotemain\'][!--quotec--] Change: [code]echo ("<img src=\"$imgpath\"alt="Welcome to"/>");[/code] To: [code]echo "<img src='". $imgpath. "' alt='Welcome to'/>";[/code] [/quote] Thanks it worked but why? If you don't mind or point me to a page in the Manual.
  6. Why won't this work? [PHP Code] <?php // Generate random number from 1-10 $imgnum = rand(1, 10); // Set image path and file name with generated number $imgpath = "images/TopBanner" . $imgnum . ".jpg"; // Display image echo ("<img src=\"$imgpath\"alt="Welcome to"/>"); ?> [/PHP Code] I can't validate my page because the banner image has no alt and no closing tag but I get a error when I try the above. Here is my include file. [PHP Code] <?php include ("randimage.php"); ?> [/PHP Code]
  7. Wow I'm dumb thanks but this can be done in PHP as a include right? Sorry for the noob question and thanks.
  8. How can I make this <h1 id="siteName" align="center"><script language="JavaScript"> <!-- image = new Array image[1]="images/TopBanner1.jpg" image[2]="images/TopBanner2.jpg" image[3]="images/TopBanner3.jpg" image[4]="images/TopBanner4.jpg" image[5]="images/TopBanner5.jpg" image[6]="images/TopBanner6.jpg" image[7]="images/TopBanner7.jpg" image[8]="images/TopBanner8.jpg" image[9]="images/TopBanner9.jpg" image[10]="images/FlowersBanner.jpg" // Create a random number between 1 and ten random_num = (Math.round((Math.random()*9)+1)) document.write("<img src=\"" + image[random_num] + "\">"); //--> </script></h1> Look more like this <?echo $banner?> I would like to have the ability to change the banner images with out going to every page or renaming then every time?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.