Jump to content

OOP

Members
  • Posts

    146
  • Joined

  • Last visited

Posts posted by OOP

  1. Hi there,

    The action attribute specifies where to send the form-data when a form is submitted so you need to replace the '#' with your target file. Now, I don't know what you are doing in your PHP file but the global array $_POST will have the value of all of your form inputs fields which can be used in order to process your contact form. For example, in order to get the value of the input field "fullname" you can do something like this

     

    $fullName = $_POST['fullname];

     

    Not to forget to say that you must not trust any inputs and must clean all before using in your script 

     

    Hope this is easy to understand

  2. You need to execute the query against your database using the mysql_query($query). You are not doing anything in your code and that is why your information is not getting inserted in the database. One more thing, the form method should be "post" instead of "get"

  3. I tried you code on my PC and it works fine except that it shows the thanks message twice. Once before the form, and the other after the form upon successful form submission. I have modified the code a bit, you may try it.

     

    <html>
    <head>
    </head>
    <body>
    <?php
    if (isset($_POST['submit'])) {
    
    if ( empty($_POST['email'])
    ||
    !preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST['email'])) {
    $msg = 'please provide a valid email';
    } else {
    
    $email = $_POST['email'];
    $recipient = "myemail@myemail.com";
    $subject = "Contact Form Email Subject";
    $message = "your email message";
    $mailheader = "From: $email \n";
    mail($recipient, $subject, $message, $mailheader) or die("Error!");
    $msg = "<font color='green' size='3'>Thank You for your message.</font>";
    }
    }
    ?>
    <form method="POST">
    <p align="center">
    Enter your valid email id: <br> <input type="text" name="email"> <br>
    <input type="submit" name="submit" value="Subscribe now!">
    
    </form>
    <?php
    echo $msg;
    ?>
    </body>
    </html>
    

  4. Hi there,

    you can simply change your statement to the below:

    if (!isset($_SESSION['user_level']) || ( ($_SESSION['user_level'] != 'A') AND ($_SESSION['user_level'] != 'B')) ) {
    //redirect to the restricted page notice
    }
    

     

    That should work

  5. Hi there,

    In order to remove the smarty engine code, just remove the below lines from the file index.php

     

     

     

    // This line is needed in order to include the smarty engine class[/color]

    require("comm/Smarty.class.php");

     

     

    // In here, you are creating a new smarty engine object and asking it

    // to display the books list using the template "index.tpl"

    $smarty = new Smarty;

    $smarty->assign("book",$book);

    $smarty->display('index.tpl');

     

    But you need to edit the code inside "index.tpl" and remove any reference to smarty inside it, I mean use pure PHP to display the book list.

     

    I hope that answers your question

  6. Hi there,

    There is nothing wrong with your validation code but you don't need to the use the header() to redirect the same page again. In the form action attribute, you can put the value "reg.php" as your script that will handle the validation.

     

    
    if(!isset($_POST['submit'])){
    <form action="reg.php" method="post">
    the rest of the fields here
    <input type="submit" name="submit" />
    </form>
    }else{
    
    if ($_POST['email1'] !== $_POST['email2']) {
      $error='email_no_matchname';
    }
    else {
    .
    .
    .
    .
    
    }
    

     

    regards

     

     

     

     

     

     

×
×
  • 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.