Jump to content

11Tami

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Posts posted by 11Tami

  1. Thanks I'm still looking right at it but don' t see how the "the following information has been submitted" is launched. I see where it is located but don't see what is connecting to it.

    Reason I am asking is I asked here how to include an echo in the same page when something is submitted. Thank you very much.
  2. OK I'm trying it, look like I'll need to put the "if" submit, on the bottom but I still need the form. Because the submit button is what sends the field to the email.

    [code]<?php
    while ($row = mysql_fetch_array($result))
    //other stuff up here that works fine. That pops up this form.
    {
    $mailto = 'emailaddress@whatever.com';
    echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='text' name='sendingfield' size=15>
    <input type='submit' name='submit' value='submit' /></form>;
    $another = $_POST['sendingfield']; //field that sends to email when submit is pushed'
    $subject = 'Subject' for email;
    $uself = 0;
    $sep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ; //puts fields into email correctly.
    $messageproper = 'Filled field listed in email field: $another\n'; 
    mail($mailto, $subject, $messageproper, 'From:' . $sep . 'Reply-To:' . $sep);"}
    if ($_POST['submit']){echo 'email sent';}}
    ?>  [/code]
  3. Chronister, thank you for tapping into what I am trying to do even though I am having a hard time explaining it. All I am trying to do is get the echo, submission successful, type message to appear when the form is sent. But to show up on the web page itelf! Not the usual white echo page. So I'll take a look at what you gave me and see if it will work. Thanks a lot!
  4. Thanks that makes sense, never thought of it. I tried this to simplify it even more and finally got rid of the usual php errors. Tell me if I did correctly what you were trying to get me to do. The submit button appears with the form field now finally. But when I enter anything into the form field and click on submit it says web page can't be found and this is in the browser search bar. %22.$_SERVER[     whatever that means. I think it means instead of staying on the same php page while sending the email the browser is looking for a web page named
    %22.$_SERVER['PHP_SELF']. Any way to get past that?

    This code is supposed to read the code from its own page instead of another elsewhere, and then send to an email with whatever is in the form field when the submit button is pushed. Still not working. Can someone tell me how to get this line to work <form action='".$_SERVER['PHP_SELF']."' method='post'>
    so it doesn't have to call a form from a separate page? Or maybe you can see something else wrong in the following code.

    <?php
    $mailto = 'website@whatever.com';
    $another = $_POST['another']; 
    $subject = 'Email subject'; 
    $headers = "From: '$another'" . "\n" . 
    $messageproper = 'Another field: $another\n'; 
    mail('$mailto','$subject',$messageproper,$headers);
    ?>
    <form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='text' name='$another' size=15>
    <input type='submit' name='submit' value='Submitting' /></form>

    Regarding the previous one I was using with the form at the top, with the way its set up the action does send, I only started having problems when I got to this part.
    The reason why I am trying to do it this way is just to get the echo messages when the email is sent to appear on the page it is sending from. If anyone knows of another way such as using <?php 
    include('sendemail.php');

    Pleae let me know. Thank you very much.
  5. I'm stripping it down completely. The problem seems to be here. When open this in a browser it does not like the line with the POST.
    $another = $_POST['anotherfield'];
    The error message says. Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
    Does anyone know why the line with the $_Post won't parse correctly? Thanks.

    <?php
    echo "
    $mailto = 'websitename@whatever.com';
    <form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='text' name='$mailto' size=15>
    <input type='text' name='$another' size=15>
    <input type='submit' name='submit' value='Submitting' /></form>;
    $another = $_POST['anotherfield'];
    $subject = 'Email subject';
    $uself = 0;
    $headersep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ;
    $messageproper = 'The E-mail: $mailto\n' . 'Another field: $another\n'; 
    mail($mailto, $subject, $messageproper, 'From: '$mailto\' <$mailto>' . $headersep . 'Reply-To: \'$mailto\' <$mailto>' . $headersep);";
    ?> 
  6. Here's what I have right now.
    [quote]<?php
    $con = mysql_connect("my","database","password") OR die('Could not connect: ' . mysql_error());
    mysql_select_db("database", $con) OR die(mysql_error());

    if(!$_POST){
    ?>
      <form action="" method="post">
        <input type="text" size="12" name="websitename" value="<?=$_POST['websitename']?>"/>
        <input type="submit" value="submitting" />
      </form>
    <?php
    }

    else{
      $modify = mysql_real_escape_string($_POST['websitename']);
      $query = "SELECT websitename FROM tablename WHERE websitename = '$modify'";
      $result = mysql_query($query) or die('Error with query' . mysql_error());

      while ($row = mysql_fetch_array($result)) {
        // and on to the sending form fields to an email address.
        $mailto = 'emailaddress@whatever.com';
        $another = $_POST['anotherfield'];
        echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
              <input type='text' name='$mailto' size=15>
              <input type='text' name='$another' size=15>
              <input type='submit' name='submit' value='Submitting' /></form>";
        $subject = 'Email subject';
        $uself = 0;
        $headersep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ;
        $messageproper = 'The E-mail: $mailto\n' . 'Another field: $another\n'; 
        mail($mailto, $subject, $messageproper, 'From: '$mailto\' <$mailto>' . $headersep . 'Reply-To: \'$mailto\' <$mailto>' . $headersep); ";}}
    ?>  [/quote]
  7. How do you guys highlight the code like that. Thanks a lot. I saw that extra /> shortly before you gave it to me.
    This is ok. '\n' ;
    and I deleted all the test fields until I get it working better.
    $test = $_POST['$row']; etc.
    I am pretty sure I still need this before the brackets "; to close the first double quote found here  echo "<form action PHP SELF etc.

    When I do the ending like this without the last echo
    $headersep); ";}}
    I can finally get the last submit fields on the web page! Which at least makes it visible without the error messages finally. What I'm trying to do is get the form to send using this $_SERVER['PHP_SELF'] instead of sending to a separate php form.

    But for some reason the the last form won't send even if I put my own email address into the $mailto variable found here.
    $mailto = 'mywebaddress@whatever.com';

    So can anyone see a reason why the last form in this code won't send to an email, using this for the form action?
    echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>

    Once I get it sending finally, I can figure out the rest. Thank you very much!
  8. Hello, I am getting this error message on the following code.
    Parse error: parse error, unexpected $ in the ending line  ?>
    Its says it doesn't like the ending closing php tag. Is it looking for something else right before it or can someone see what is wrong? This code just get something out of a database and when it gets it, then it sends it and another input field to an email address. Hope someone can help. Thank you very much.

    <?php
    $con = mysql_connect("my","database","password")
    OR die('Could not connect: ' . mysql_error());
    mysql_select_db("database", $con) OR die(mysql_error());
    if(!$_POST){?><form action="" method="post"><input type="text" size="12" name="websitename"
    value="<?=$_POST['websitename']?>" />" /><input type="submit" value="submitting" /></form><?}
    else{$modify = mysql_real_escape_string($_POST['websitename']);
    $query = "SELECT websitename FROM tablename WHERE websitename = '$modify'";
    $result = mysql_query($query) or die('Error with query' . mysql_error());
    while ($row = mysql_fetch_array($result))
    {
    // and on to the sending form fields to an email address.
    $mailto = $_POST['anemailaddress'];
    $test = $_POST['$row'];
    echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='text' name='$mailto' size=15>
    <input type='text' name='$test' size=15>
    <input type='submit' name='submit' value='Submitting' /></form>";
    $subject = 'Email subject';
    $uself = 0;
    $headersep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ;
    'The E-mail: $mailto\n' . 'Testing field: $test\n';
    mail($mailto, $subject, $messageproper, 'From: \'$mailto\' <$mailto>' . $headersep . 'Reply-To: \'$mailto\' <$mailto>' . $headersep);}}";
    echo "this line will work when the php self works, right now I get the last error message instead";
    ?>


  9. Hello, can actual php functions be pulled from a database and work?
    I tried pulling out a small one inside other php that pulls items out of a database but pulling a php function out instead of just text didn't work. Can it be done? For instance how do people fill out new forms and such if a certain something is triggered and so on?

    Thank you very much.

  10. This must be where the problem is then. I have a table called "names." But then it goes directly into the actual names of bobby etc. That way whatever I put into the "bobby" field etc. is what will be pulled. I copied and pasted this right off the table called "names." It shows the database information at the top from mysql then the field informaton underneath of it. For the field type I used "text," instead of varchar."

    Server:  Database: pulldata   Table: names
    Browse Insert etc.
    Field Type
    bobby text                 
    mandi text                   
    Mike text 

    Then under each name I can insert their information. The inserted information is the information I am trying to pull.  Thanks much.             
  11. Post holiday break. You still around obsidian? Still getting this error
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource, for this line $row = mysql_fetch_array($result);

    So I'll give you everything I have, maybe you can see the error.
    Heres the php
    <?php
    $link = mysql_connect('mysql9etc', 'login', 'password');

    $db_selected = mysql_select_db('login', $link);

    $result = mysql_query("SELECT name FROM names WHERE 'name' = '$_POST[username]' LIMIT 1");

    $row = mysql_fetch_array($result);
    echo "<p>$row[name]</p>";

    ?>

    Here's the form.
    <form action="test.php" method="post">
    <input type="text" name="username" size="14" value"username" />
    <input type="submit" value="submit" />
    </form>

    Then I have a table named "names" and have the column "bobby" in it. With "this is in the bobby field" in the bobby field. When I enter "bobby" into the form, I get the error. Should something else be listed in this field like "username" instead?
    echo "<p>$row[name]</p>";

    Please get back to me, thanks very much.
  12. For some reason its saying the fetch string isn't a valid argument. But it might be because I needed to alter this string.
    $result = mysql_query("SELECT names WHERE `names`='$_POST[username]' LIMIT 1");

    I don't know how to say select the items listed in the actual name fields(bobby) etc. from the table called "names." It didn't read like this the way you had it listed. How to adjust for this? Thanks.
  13. Hi this is just code that pulls items out of a database. Right now it is pulling a row from the field "names." From the table called "users." From a database. How can I get it to pull only a row with a name of "bobby" for instance? I can't seem to find any information online on how to pull a row only with a particular id. Please let me know, thank you very much.

    <?php
    $link = mysql_connect('host', 'username', 'password');

    $db_selected = mysql_select_db('database', $link);

    $query = "SELECT names FROM users";

    $result = mysql_query($query);

    while ($row = mysql_fetch_array($result))
    {
    print "<p>$row[names]</p>";
    }

    ?>
  14. Hi this is a log in script I found here:http://evolt.org/php_login_script_with_remember_me_feature?from=100&comments_per_page=50

    I am going to add the login part of the script to an add/modify link so that when somone wants to add their own items it will add them and then they can also modify their own added items when they come back later. I can do the new form and database fields myself for the add and modify pages for each person. But this is where I am stuck.

    How do I make it so that when a different person is logged in, their own page or link to a page will appear for them to insert their items into? For instance I think this is the part I need to adjust in the code further below, but someone who know more about database and php might tell me otherwise.

    /* Validate that password is correct */
    if($password == $dbarray['password']){
    return 0; //Success! Username and password confirmed

    Instead of just success, I would need an html page to appear just for this person
    when their ursername and password are correct. How can I do this? thank you very much. Please get back to me. Below is all of the code for the login.php

    <?

    /**
    * Checks whether or not the given username is in the
    * database, if so it checks if the given password is
    * the same password in the database for that user.
    * If the user doesn't exist or if the passwords don't
    * match up, it returns an error code (1 or 2).
    * On success it returns 0.
    */
    function confirmUser($username, $password){
    global $conn;
    /* Add slashes if necessary (for query) */
    if(!get_magic_quotes_gpc()) {
    $username = addslashes($username);
    }

    /* Verify that user is in database */
    $q = "select password from users where username = '$username'";
    $result = mysql_query($q,$conn);
    if(!$result || (mysql_numrows($result) < 1)){
    return 1; //Indicates username failure
    }

    /* Retrieve password from result, strip slashes */
    $dbarray = mysql_fetch_array($result);
    $dbarray['password'] = stripslashes($dbarray['password']);
    $password = stripslashes($password);

    /* Validate that password is correct */
    if($password == $dbarray['password']){
    return 0; //Success! Username and password confirmed
    }
    else{
    return 2; //Indicates password failure
    }
    }

    /**
    * checkLogin - Checks if the user has already previously
    * logged in, and a session with the user has already been
    * established. Also checks to see if user has been remembered.
    * If so, the database is queried to make sure of the user's
    * authenticity. Returns true if the user has logged in.
    */
    function checkLogin(){
    /* Check if user has been remembered */
    if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
    $_SESSION['username'] = $_COOKIE['cookname'];
    $_SESSION['password'] = $_COOKIE['cookpass'];
    }

    /* Username and password have been set */
    if(isset($_SESSION['username']) && isset($_SESSION['password'])){
    /* Confirm that username and password are valid */
    if(confirmUser($_SESSION['username'], $_SESSION['password']) != 0){
    /* Variables are incorrect, user not logged in */
    unset($_SESSION['username']);
    unset($_SESSION['password']);
    return false;
    }
    return true;
    }
    /* User not logged in */
    else{
    return false;
    }
    }

    /**
    * Determines whether or not to display the login
    * form or to show the user that he is logged in
    * based on if the session variables are set.
    */
    function displayLogin(){
    global $logged_in;
    if($logged_in){
    echo "<h1>Logged In!</h1>";
    echo "Welcome <b>$_SESSION[username]</b>, you are logged in. <a href=\"logout.php\">Logout</a>";
    }
    else{
    ?>

    <h1>Login</h1>
    <form action="" method="post">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
    <tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr>
    <tr><td colspan="2" align="left"><input type="checkbox" name="remember">
    <font size="2">Remember me next time</td></tr>
    <tr><td colspan="2" align="right"><input type="submit" name="sublogin" value="Login"></td></tr>
    <tr><td colspan="2" align="left"><a href="register.php">Join</a></td></tr>
    </table>
    </form>

    <?
    }
    }


    /**
    * Checks to see if the user has submitted his
    * username and password through the login form,
    * if so, checks authenticity in database and
    * creates session.
    */
    if(isset($_POST['sublogin'])){
    /* Check that all fields were typed in */
    if(!$_POST['user'] || !$_POST['pass']){
    die('You didn\'t fill in a required field.');
    }
    /* Spruce up username, check length */
    $_POST['user'] = trim($_POST['user']);
    if(strlen($_POST['user']) > 30){
    die("Sorry, the username is longer than 30 characters, please shorten it.");
    }

    /* Checks that username is in database and password is correct */
    $md5pass = md5($_POST['pass']);
    $result = confirmUser($_POST['user'], $md5pass);

    /* Check error codes */
    if($result == 1){
    die('That username doesn\'t exist in our database.');
    }
    else if($result == 2){
    die('Incorrect password, please try again.');
    }

    /* Username and password correct, register session variables */
    $_POST['user'] = stripslashes($_POST['user']);
    $_SESSION['username'] = $_POST['user'];
    $_SESSION['password'] = $md5pass;

    /**
    * This is the cool part: the user has requested that we remember that
    * he's logged in, so we set two cookies. One to hold his username,
    * and one to hold his md5 encrypted password. We set them both to
    * expire in 100 days. Now, next time he comes to our site, we will
    * log him in automatically.
    */
    if(isset($_POST['remember'])){
    setcookie("cookname", $_SESSION['username'], time()+60*60*24*100, "/");
    setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100, "/");
    }

    /* Quick self-redirect to avoid resending data on refresh */
    echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]\">";
    return;
    }

    /* Sets the value of the logged_in variable, which can be used in your code */
    $logged_in = checkLogin();

    ?>
  15. Thanks but can you make it more simple for someone who doesn't do scripting all the time? I have no clue what you just said. I know there are many types of strings. I don't see a difference between a string and an executable string.  I believe these are variables $ but everything I saw said eval can use variables. So I don't understand your description. Please explain the difference someone and explain it like your are talking to someone in high school who hasn't done much scripting? Thank you very much.
  16. Hello, A small problem I think to anyone that knows about php. I am pulling a few items from mysql server database but even though the php works it is reading wrong in the browser. For instance in this whole string at the very end Mozilla and Opera are showing this much of the php. At the very end of the print string it is only showing "; ?>  When the end of the string should be invisible. Can tell me what to do to make the end of the print string invisible in these browsers? Thank you very much.

    while ($row = mysql_fetch_array($result))
    {
    print "<p><a style='font-weight: bold; color: rgb(0, 0, 140); font-size: 14px;' href='$row[url]' target='_blank'>$row[webname]</a>&nbsp;&nbsp;<span style='font-size: 14px; font-family: arial,sans-serif; padding-right: 3px;'>$row[description]</span></p>"; } ?>
×
×
  • 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.