Jump to content

jsparrow

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jsparrow's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks. Yea, just made the .inc file a div and removed all the other html and that worked.
  2. I have a basic web page that is a rectangle and I'm trying to put a box within this rectangle at the top, but it has a space that I can not figure out how to get rid of. Here is the code for the index.php, top.inc and align.css files: index.php <html> <head> <title> Home </title> <link rel="stylesheet" href="align.css" type="text/css"> </head> <body> <div id="wrapper"> <div id="logo"> <?php include ("top.inc") ?> </div> </div> </body> </html> top.inc <html> <head> </head> <p> Show this to me </p> </html> align.css body { font-family: Arial, Helvetica, sans-serif; font-size:100%; padding:0px; background-color:white; text-align:center; } #wrapper { width:600px; height:850px; margin:70px auto auto auto; background-color:yellow; border-style:solid; border-width:2px; border-color:green; } #logo { width:600px; height:280px; margin:0px auto 0px auto; background-color:orange; } How do I get rid of the space at the top of the top.inc and make if flush with the top of the wrapper?
  3. I have been learning and practicing PHP and mySQL on a laptop that I have a server set up on. My PHP index file accesses the database using the mysqli_connect('localhost', 'root', 'mypassword'); When I upload these files to my web host I put the files in the public directory so that they are accessable on the internet. My worry is that some type of web scraper utility can download the php file and read my login name and password. Are PHP files somehow protected from being downloaded in some type of scraper utility even though they are in a public folder or should I put it in another folder?
  4. Thanks PFMaBiSmAd. After moving the form start to after the <?php foreach statement and containing the entire form within the foreach statement it worked.
  5. Anyone have any advice on this. I've been trying to work it out over the weekend and still not working.
  6. I checked that and it's not deleting anything. I'm not sure where this is falling down.
  7. Under your set variables you have: //Set Variables $id = $_POST['id']; $table = $POST['table']; Fix the $table variable to $_POST['table'];
  8. I have a php index page that includes a form page with a delete button for that row. When I hit the delete button nothing happens. I am not sure if the variable is not passing or if the index.php page is not processing it correctly. Here is the index page that includes the form page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Welcome Page Test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <?php if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } if (isset($_GET['addjoke'])) { include 'form.html.php'; exit(); } $link = mysqli_connect('localhost', 'root', 'password'); if (!$link) { $output = 'Unable to connect to the database server.'; include 'output.html.php'; exit(); } if (!mysqli_set_charset($link, 'utf8')) { $output = 'Unable to set database connection encoding.'; include 'output.html.php'; exit(); } if (!mysqli_select_db($link, 'database')) { $output = 'Unable to locate the database.' . mysqli_error($link); include 'output.html.php'; exit(); } if (isset($_POST['joketext'])) { $joketext=mysqli_real_escape_string($link,$_POST['joketext']); $sql = "INSERT INTO jokes2 (joketext, jokedate) VALUES ('$joketext', CURDATE() )"; if (!mysqli_query($link,$sql)) { $error = 'Error adding submitted joke: ' . mysqli_error($link); include 'error.html.php'; exit(); } header('Location: .'); exit(); } if (isset ($_GET['deletejoke'])) { $id= mysqli_real_escape_string($link,$_POST['id']); $sql = "DELETE FROM jokes2 WHERE id='$id'"; if(!mysqli_query($link,$sql)) { $error= 'Error deleting actor: ' . mysqli_error($link); include 'error.html.php'; exit(); } header('Location: .'); exit(); } $result = mysqli_query($link, 'SELECT jokes2.id, joketext, name, email FROM jokes2 INNER JOIN author ON authorid = author.id'); if (!$result) { $error = 'Error retrieving data' . mysqli_error($link); include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $jokes[] = array('id'=>$row['id'], 'joketext'=>$row['joketext'], 'name'=>$row['name'], 'email'=>$row['email']); } include 'jokes.html.php'; ?> </body> </html> The $_GET array should be getting the variable id passed when the Delete button is pressed on the form, but nothing is happening when I press the button. Here is the form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Welcome Page Test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <p> <a href="?addjoke">Add Joke </a> </p> <p> Here are all the jokes: </p> <form action="?deletejoke" method="post"> <?php foreach($jokes as $joke): ?> <p> <?php echo htmlspecialchars($joke['id'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['joketext'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['name'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['email'], ENT_QUOTES, 'UTF-8'); ?> <input type="hidden" name="id" value="<?php echo $joke['id']; ?>" /> <input type="submit" value="Delete"/> </p> </form> <?php endforeach; ?> </p> </body> </html> All of my other variables seem to be passing just fine. Any ideas why this one is a problem?
  9. That fixed it. Thx much. Was going cross eyed trying to figure that out.
  10. The notices of the unassigned page comes up directly from hitting the submit button on the form requesting firstname and lastname.
  11. The error and text I am getting is: Notice: Undefined index: firstname in C:\Apache2.2\htdocs\formtest\reg5.php on line 12 Notice: Undefined index: lastname in C:\Apache2.2\htdocs\formtest\reg5.php on line 13 Welcome to our site, I'm really confused since I have another page that is almost similar to this and it works fine. Is the problem on the html page with some code issue and it not passing the firstname & lastname - or - is it a problem on the php code side not interpreting what was sent correctly? Thx.
  12. I have been going back over this and can not locate the problem. I really need someone else's fresh eyes to look at this for me. I am trying to have an html page send info to a php page using POST. I keep getting the error Undefined index *** on line **. I have done this before, but can not locate the problem. Here is the html code for the input page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Pre-Registration</title> <link rel="stylesheet" type="text/css" href="preregistration.css"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <h1>Pre-Registration</h1> <h3> Please fill out the below pre-registration form. </h3> <form method="post" action="reg5.php" enctype="text/plain" onReset="return setDisabled()"> <table> <tr> <td class="name">First Name <input class="name" type="text" name="firstname"/> </td> <td class="name">Last Name <input class="name" type="text" name="lastname"/> </td> </tr> </table> <br/> <input type="submit" value="Submit" /> <input type="button" value="Reset Form" onClick="this.form.reset()" /> </form> </body> </html> And here is php code that should output: Welcome to our site, firstname lastname <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Welcome Page Test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <p> <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; echo 'Welcome to our site, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8'); ?> </p> </body> </html> Any help would be greatly appreciated.
×
×
  • 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.