Jump to content

Truman

Members
  • Posts

    109
  • Joined

  • Last visited

Posts posted by Truman

  1. This is interesting...when I open a file in browser ( file > open ) it shows "password" and "confirm password". But when I run it through server ( localhost ) nothing again. Any idea why this glitch?

  2. No, and the case is that other inputs are there ( Email Address etc. ). Now I will correct this mistake.

     

    edit: After eding <body> everything stays the same, no password.

  3. I created a HTML registration form with input type password but when I run HTML in my xampp server I see no "password" nor "confirm password". Verification shows that my syntax is OK.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Registration Form</title>
    </head>
    <!-- Script 6.1 - register.html -->
    <div><p>Please, complete this form to register:</p>
    <form action="handle_reg.php" method="post">
    <p>Email Address: <input type="text" name="email" size="30" /></p>
    <p>Password: <input type="password" name="password" size="20" /></p>
    <p>Confirm Password: <input type="password" name="confirm" size="20" /></p>
    <p>Year you were born: <input type="text" name="year" value="YYYY" size="4" /></p>
    <p>Favorite Color:
    <select name="color">
    <option value="">Pick One</option>
    <option value="red">Red</option>
    <option value="yellow">Yellow</option>
    <option value="green">Green</option>
    <option value="blue">Blue</option>
    </select></p>
    <p><input type="checkbox" name="terms" value="Yes" />I agree to the terms (whatever they may be).</p>
    <input type="submit" name="submit" value="Register" /></form>
    </div>
    </body>
    </html>
    
  4. Ok, I see it> $_POST['last_name];

    I forgot a single quotation mark after last_name.

     

    And I also spotted a mistake in line 14. Now everything is fine. I will do my best to try to figure out these beginners mistakes before I post here.

  5. I have a problem with this code:

    <!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Forum Posting</title>
    </head>
    <body>
    <?php // Script 5.2 - handle_post.php
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name];
    $posting = $_POST['posting'];
    $name = $first_name . ' ' . $last_name;
    print "<div>Thank you, $name, for your posting":<p>$posting</p></div>";
    ?>
    </body>
    </html>
    

    After I enter data to html form it says:
    Parse error: syntax error, unexpected 'posting' (T_STRING), expecting ']' in C:\xampp\htdocs\my-site\handle_post.php on line 12

  6. Do you want me to place this file on external server? I'm not sure how to do that yet. :sorry:

    If with html file is the same procedure with wordpress using FileZilla I may try but don't feel like opening new free server address right now.

  7. This is my code:

    <!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Forum Posting</title>
    </head>
    <body>
    <!-- Script 5.1 posting.html -->
    <div><p>Please complete this form to submit your posting:</p>
    <form action="handle_post.php" method="post">
    <p>First Name: <input type="text" name="first_name" size="20" /></p>
    <p>Last Name: <input type="text" name="last_name" size="20" /></p>
    <p>Email Address: <input type="text" name="email" size="30" /></p>
    <p>Posting: <textarea name="posting" rows="9" cols="30"></textarea></p>
    <input type="submit" name="submit" value="Send My Posting" />
    </form>
    </div>
    </body>
    </html>
    

    and this is what I receive:

    2w7kf8g.png

     

    Any idea why this is happening?

    • Like 1
  8. Thank you. Now I'm working on ecommerce task. I made a html form for entering data about purchasing and php to handle it and calculates things.

    <!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTDxhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <meta http-equiv="Content Type" content="text/html; charset=utf-8"/>
      <title>Product Cost Calculator</title>
    </head>
    <body><!-- Script 4.1 - calculator.html -->
    <div><p>Fill out this form to calculate the total cost:</p>
    <form action="handle_calc.php" method="post">
    <p>Price: <input type="text" name="price" size="5" /></p>
    <p>Quantity: <input type="text" name="quantity" size="5" /></p>
    <p>Discount: <input type="text" name="discount" size="5" /></p>
    <p>Tax: <input type="text" name="tax" size="3" /> (%)</p>
    <p>Shipping method: <select name="shipping">
    <option value="5.00">Slow and steady</option>
    <option value="8.95">Put a move on it.</option>
    <option value="19.36">I need it yesterday!</option>
    </select></p>
    <p>Number of payments to make:<input type="text" name="payments" size="3" /></p>
    <input type="submit" name="submit" value="Calculate!" />
    </form>
    </div>
    </body>
    </html>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <title>Product Cost Calculator</title>
     <style type="text/html" media="screen">
     .number{font-weigh="bold";}
     </style>
    </head>
    <body>
    <?php // Script 4.2 - handle_calc.php
    $price = $_POST['price'];
    $quantity = $_POST['quantity'];
    $discount = $_POST['discount']
    $tax = $_POST['tax'];   
    $shipping = $_POST['shipping'];
    $payments = $_POST['payments'];
    $total = $price * $quantity;
    $total = $total + $shipping;
    $total = $total - $discount;
    $taxrate = $tax/100;
    $taxrate = $taxrate + 1;
    $tax = $total * $taxrate;
    $monthly = $total / $payments;
    Print "<p>You have selected to purchase: <br />
    <span class=\"number\">quantity></span> widget(s) at: <br />
    $<span class=\"number\">$price</span> price each plus a <br />
    $<span class=\"number\">$shipping</span> shipping cost and a <br />
    <span class=\"number\">$tax</span> percent tax rate. <br />
    After your $<span=\"number\">$discount</span> discount, the total cost is 
    $<span class=\"number\">$total</span>.<br />
    Divided over<span class=\"number\">$payments</span> monthly payments that would be $<span class=\"number\">$monthly</span>each.</p>"
    ?>
    </body>
    </html> 
    

    The message that I receive is:

    Parse error: syntax error, unexpected '$tax' (T_VARIABLE) in C:\xampp\htdocs\my-site\handle_calc.php on line 16

     

    I don't understand what is wrong in line 16: $tax = $_POST['tax'];

    The php code checker signalizes the same error.

  9. I minor problem this time. I'm practising sending data to server without html form. So, the first code is html with <a href=...> and the second is php that receives data from html.

    <!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"lang="en">
    <head>
    <meta http-equiv="Content Type" content="text/txt" charset="utf-8"/>
    <title>Greetings!</title>
    </head>
    <body>
    <!-- Script 3.6 - hello.html --> 
    <div><p>Click a link to say hello:</p>
    <ul>
     <li><a href="hello.php?name=Michael">Michael</a></li> 
     <li><a href="hello.php?name=Celia">Celia</a></li>
     <li><a href="hello.php?name=Jude">Jude</a></li>
     <li><a href="hello.php?name=Sophie">Sophie</a></li>
     
    </ul>
    </div>
    </body>
    </html>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
    1.0 Transitional//EN"
    2 "http://www.w3.org/TR/xhtml1/DTD/
    xhtml1-transitional.dtd">
    3 <html xmlns="http://www.w3.org/1999/xhtml"
    xml:lang="en" lang="en">
    4 <head>
    5 <meta http-equiv="content-type"
    content="text/html; charset=utf-8" />
    6 <title>Greetings!</title>
    7 </head>
    8 <body>
    9 <?php // Script 3.7 hello.php 
        ini_set ('display_errors', 1);
    	error_reporting (E_ALL | E_STRICT);
    	$name = $_GET['name'];
    	print "<p>Hello,<span style=\"font-weight:bold;\">$name</span>!</p>";
    	?>
    22 </body>
    23 </html>
    

    This time I received:

    3 4 5 6 7 8 9

    Hello,Michael!

    22 23

    Why those numbers appeared? They are propably lines in notepad++.

  10. A friend helped me with editing code, this is how it should look:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
        <title>Your Feedback</title>
    </head>
    <body>
    <?php // Script 3.3  handle_form.php
    // This page receives data from feedback.php
    // It will receive: title, name, email, response, comments, and submit in $_POST.
    $title = $_POST['title'];
    $name = $_POST['name'];
    $response = $_POST['response'];
    $comments = $_POST['comments'];
    print "<p>Thank you, {$title} {$name}, for your comments</p>
    <p>You stated that you found this example to be '{$response}' and added:<br />{$comments}</p>";
    ?></body>
    </html>
    
    
    

    So basically, he only added curly braces in quotes to variables in paragraph...

  11. Yes, I gave a php extension and I use XAMPP that has php installed.

    By the way, it did execute php code for some simple things such as phpinfo function. Whenever I made a mistake that needed to be fixed after I did it the server didn't respond well.

  12. No hidden extension, I follow the book "PHP for the web" by Larry Ullman. Everything is as in the book. After first few fails I even copy-pasted codes but nothing changes...

    After rerunning your edited code it says:

     

    Thank you, '.$title.' '.$name.', for your comments'; echo '

    You stated that you found this example to be \''.$response.'\' and added:
    '.$comments.'

    '; ?>

  13. Now the response is:

    Thank you, '.$title.' '.$name.', for your comments'; echo '

    You stated that you found this example to be \''.$response.'\' and added:
    .'$comments.'

    '; ?>

     

    Using print should be ok, I have a feeling that something is wrong with my server, XAMPP is in actions but I don't get why these kind of responses for different files that I tried to execute.

  14. I am sorry, I don't understand your previous comment.

     

    And I have a similar problem with my next task. I created two files ( html form and php ) but it doesn't execute properly.

    Check it if you wish:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Feedback Form</title>
    </head>
    <body>
    <!-- Script 3.1 feedback.html -->
    <div><p>Please, complete this form to submit a feedback:</p></div>
    <form method="post" action="handle_form.php">
    <p>Name: <select name="title">
    <option value="Mr.">Mr.</option>
    <option value="Mrs.">Mrs.</option>
    <option value="Ms.">Ms.</option>
    </select><input type="text" name="name" size="20" /></p>
    <p>Email Address: <input type="text" name="email" size="20" /></p>
    <p>Response: This is...
    <input type="radio" name="response" value="excellent" /> excellent
    <input type="radio" name="response" value="okay" />Okay
    <input type="radio" name="response" value="boring" />boring</p>
    <p>Comments: <textarea name="comments" rows="3" cols="30"></textarea></p>
    <input type="submit" name="submit" value="Send My Feedback" />
    </form>
    </div>
    </body>
    </html>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html"; charset="utf-8"/>
    <title>Your Feedback</title> 
    </head>
    <body>
    <?php // Script 3.3  handle_form.php
    // This page receives data from feedback.php
    // It will receive: title, name, email, response, comments, and submit in $_POST.
    $title = $_POST['title'];
    $name = $_POST['name'];
    $response = $_POST['response'];
    $comments = $_POST['comments'];
    print "<p>Thank you, $title $name, for your comments</p>
    <p>You stated that you found this example to be '$response' and added:<br />$comments</p>";
    ?>
    </body>
    </html>
    
  15. Yes, it's with utf-8. It's interesting that when I first wrote the code I made a mistake on line 18. When I corrected that mistake and tried to execute the code but the message was the same.

  16. I corrected this line to:

     print "<h1>Basic Info</h1><p>My name is $name, I am $age years old.<br/>My nationality is $nationality. My lastname is $lastname</p>";
    

    ...but it still doesn't work and the message I receive is the same.

  17. I'm working on my php skills and I run .php files on XAMPP server but it signals parse error even when php code checker sees no problem.

    This is one of the codes that I wrote:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
    1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/
    xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml"
    xml:lang="en" lang="en">
     <head>5 <meta http-equiv="content-type"
    content="text/html; charset=utf-8" />
     <title>Quotes</title>
     </head>
     <body>
     <?php // Script 2.4 - pursue3.php
     $name = "M";
     $age = 29;
     $lastname = 'B';
     $nationality = "S";
     print "<h1>Basic Info</h1><p>My name is $name, I am $age years old.<br/>My nationality is $nationality. My lastname is $lastname</p>"
     ?>
     </body>
     </html>
     
    

    When I execute this code on my localhost it says: "Parse error: syntax error, unexpected '?' in C:\xampp\htdocs\my-site\pursue3.php on line 18"

     

    It happened with last 3 php files that I wrote. I know what a parse error is, I just don't see where I made any mistake.

  18. I'm learning PHP from w3school tutorial and I need explenation about "!", for example take a look at this code:

     

    <?php
    $int = 100;

    if (!filter_var($int, FILTER_VALIDATE_INT) === false) {
    echo("Integer is valid");
    } else {
    echo("Integer is not valid");
    }
    ?>

     

    Why is there exclamation mark in this code?

    And one more thing: if filter_validate_int ( or any other filter ) is false that is because the filter didn't catch any error and therefore, in this case integer, is valid. Did I get this correct?

×
×
  • Create New...