Jump to content

11Tami

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Posts posted by 11Tami

  1. Hello, I need some php to do something important but should be somewhat easy. But I'm not sure how to approach it. Basically I need to put a text link into some php. So that only when the text link is clicked on a small form will appear. Thats it! The rest I can figure out on my own, just need to know how the form can appear when a text link is clicked on, using php.

     

    Please let me know, and thank you very much.

  2. Hi, I need to know how to pull data from an xml file with php.
    For example, lets say I have a form field. When an xml file internet address is put into the form field and the "submit" button is pushed, I need to have just some of the xml fields appear on the page. Anyone have any basic code to get me started? I have no idea where this starts. I already know how to make forms I  just don't know how to pull the data to populate the form fields. Thank you very much.
  3. Hi, here's the first variable that works fine as is. $mailto = $_POST['email'];

    How do I add a second to it so that it sends to two different emails? Neither of the following works. Thank you very much.

    $mailto = $_POST['email']  . $_POST['email2'] ;
    $mailto = $_POST['email'], $_POST['email2'] ;
  4. Hi, I have a form that goes to mysql when a submit button is pushed. How to make some of the form fields go to an email at the same time. For example an easy summary of it:

    <?php
    If post then {
    ?>
    form fields
    <form action="<?php $_SERVER['PHP_SELF'] ;?>" method='post'>
    <input fields here>
    type='submit' name='Submit' value='Submit'>
    </form>
    <?php
    }
    else {
    $con = mysql_connect("mysql","databasename","password");
    $sql="INSERT INTO etc.
    if (!mysql_query($sql,$con))
    {die('Error: ' . mysql_error());}

    This is where I get stuck. Where to add the email fields. So that some of the above form fields will send to the email as well. I tried......
    else {
    $mailto = etc. and so on here.
    echo "form fields sent";}}
    ?>

    But it says unexpected Telse on the last else. Thank you very much.
  5. Can you please tell me why a default both of you are giving me is supposed to help? I tried that as well with no luck.

    I also tried this
    if (empty($requesteremail) || empty($requesterwebsite)) {echo "field empty please try again";}
    else {echo "email sent!";}

    So that if some of the other fields as well as requesteremail are not filled in they will go back to fill it in. But again if requesterwebsite is filled in but requesteremail is not, the echo "field is empty" won't even appear. If someone can tell me why the email isn't reading the "from" field it help me to know the right questions to ask. Thanks.
  6. $requesteremail = (!empty($_POST['requesteremail'])) ? $_POST['requesteremail'] : 'AnotherEmail@hotmail.com';

    I tried this with and without the last field and with a real email address in the last field. It doesn't help. The problem I am having is the form only sends when there is something in this form field. "requesteremail" <input type="text" name="requesteremail" size=20>

    Can someone help tell me how to fix it? Thank you very much.

  7. I think people are having trouble reading my code, its so small when I surround it with the code tags so here it is without it. generic number, I don't understand what this will do attached to it  'AnotherEmail@hotmail.com'; once I know that I'll know how to try it.
    Also, it isn't haveing any trouble reading requesteremail, its just not reading the other form fields but I'll try it anyway. So anyone else with other suggestions please let me know. Thanks!

    while  ($row = mysql_fetch_array($result)){
                if ($_POST['websitename']==""){?>

    <form method="post" action="<?php $_SERVER['PHP_SELF'] ;?>">
    <input type="hidden" value="<?php echo $row[websitename];?>" name="websitename">
    <input type="text" name="requesteremail" size=20><br /><br />
    <input type="text" name="requesterwebsite" size=20><br /><br />
    <input type="text" name="page" size=20><br /><br />
    <input type="submit" name="submit" value="Submit" /></form>
    <?php
    }
    else{
    $mailto = 'emailaddress@something.com' ;
    $subject = "Subject of email" ;
    $requesteremail = $_POST['requesteremail'] ;
    $requesterwebsite = $_POST['requesterwebsite'] ;
    $reciprocalpage = $_POST['page'] ; 
    $uself = 0;
    $sep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
    $messageproper = "$requesteremail\n" . "$requesterwebsite\n" . "$page\n";
    mail($mailto, $subject, $messageproper, "From: \"$requesterwebsite\" <$requesteremail>" . $sep . "Reply-To: \"$requesterwebsite\" <$requesteremail>" . $sep);
    echo "email sent";
    }}}//these 3 brackets needed from other mysql variables earlier.
    ?>
  8. Hello, I need help. I can't figure out why entering something in the form field "requesteremail" sends the email, but if it is empty, none of the fields will send to the email. I don't see anything in here that would cause this to happen. Please let me know why this is happening, thank you very much.

    [code]while  ($row = mysql_fetch_array($result)){
                if ($_POST['websitename']==""){?>

    <form method="post" action="<?php $_SERVER['PHP_SELF'] ;?>">
    <input type="hidden" value="<?php echo $row[websitename];?>" name="websitename">
    <input type="text" name="requesteremail" size=20><br /><br />
    <input type="text" name="requesterwebsite" size=20><br /><br />
    <input type="text" name="page" size=20><br /><br />
    <input type="submit" name="submit" value="Submit" /></form>
    <?php
    }
    else{
    $mailto = 'emailaddress@something.com' ;
    $subject = "Subject of email" ;
    $requesteremail = $_POST['requesteremail'] ;
    $requesterwebsite = $_POST['requesterwebsite'] ;
    $reciprocalpage = $_POST['page'] ; 
    $uself = 0;
    $sep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
    $messageproper = "$requesteremail\n" . "$requesterwebsite\n" . "$page\n";
    mail($mailto, $subject, $messageproper, "From: \"$requesterwebsite\" <$requesteremail>" . $sep . "Reply-To: \"$requesterwebsite\" <$requesteremail>" . $sep);
    echo "email sent";
    }}}//these 3 brackets needed from other mysql variables earlier.
    ?> [/code]
  9. Hi, I need to use a text area in a form instead of an input field so a larger amount of text can be inserted. When I try to use this

    value="<?php echo $row[databasefield];?>" like I do in my input fields
    <input value="<?php echo $row[databasefield];?>"  name="databasefield">

    and try to use it in a text area field instead.

    <textarea rows="5" cols="25" name="databasefield" value="<?php echo $row[databasefield];?>" ></textarea>

    The database property won't appear in the form like it will with an input field. How do I adjust for the text area field to show the database info instead? Right now nothing is appearing in the text area field. Thank you very much.
  10. Afraid not. This is why I need help with this because its kind of hard to explain. What it is saying is pull out a "row" only for the database field named datafield. There are two fields in the database table. One is called websitename and the other is called datafield. I am only asking for what is entered into the row of datafield. The row that I want is identified by the website name that is asked for.

    [quote]so fields in table are

    |website name| and |datafield|
    |Joes Buffet|  and |stuff in datafield|  Is the row just for Joes Buffet.[/quote]

    When somone asks for Joes Buffet, since I have $row[datafield] listed in the form, its supposed to put "stuff in datafield" into the input text field all on its own.

    The check that shows this is working is here.
    if (mysql_num_rows($result) == 0)
    {
    echo "$modify not found. Please recheck name and try again";

    If Joes Buffet or whatever is not found in the database I will get the just above error message. Right now I know its working because when I put in a bogus name, I get the error message. When I put a name that is in the database I don't get the message.

    So I think the error is here unless someone can prove to me otherwise.
    [code]while  ($row = mysql_fetch_array($result)){
    if ($_POST['text']==""){[/code]

    I have the "if" command in the "while" statement, because I didn't know another way to do it. Hope someone can help, thanks.







  11. Hi, I need some special help for this situation. I'll send you a whole bunch of helpful links if you can help me fix it. In this code you put in a web site into the first form field. When you submit the name it looks in the database to see if the name is there. If it finds the name, it then pulls out the value for a field called "datafield" from the particular website name. That field called "datafield" is then supposed to carry over to the form on the bottom of this page and appear in the form field all on its own. (Due to the value for the input field value="$row[datafield]")
    <input type="text" name="datafield" value="$row[datafield]">

    This code is a working copy and works perfectly, all except for the datafield is not carrying over to the form. Can someone help me spot the problem and why  it isn't appearing in the form field? Thank you [i]so much [/i] for your help.

    [code]<?php
    $con = mysql_connect("m","database","password")
    OR die('Could not connect: ' . mysql_error());   
    mysql_select_db("database", $con) OR die(mysql_error());   
    if(!$_POST){?><form action="" method="post"><span style='margin-left: 0px; font-weight:bold; font-family: arial,sans-serif; color: rgb(0, 0, 128); font-size: 14px;'>
    Enter a web site name to view
    link requests options. Web site names can be in upper or lower case.&nbsp;<br /><br /></span><input type="text" size="12" name="websitename" value="<?=$_POST['websitename'] ?>" />&nbsp;&nbsp;<input type="submit" style="width:107px" value="Request Options" /></form><?}
    else{$modify = mysql_real_escape_string($_POST['websitename']);   
    $query = "SELECT DISTINCT websitename, datafield FROM getname WHERE websitename = '$modify'";
    $result = mysql_query($query)  or die('Error with query' . mysql_error());
    if (mysql_num_rows($result) == 0)
    {
    echo "$modify not found. Please recheck name and try again";
    }
    while  ($row = mysql_fetch_array($result)){
    if ($_POST['text']==""){
    echo '
    <form method="post" action="">
    <input type="text" name="text"><br />
    <input type="text" name="emailaddress"><br />
    <input type="text" name="datafield" value="$row[datafield]"><br /><br /><input type="submit" value="submit"></form>
    ';
    }
    else
    {
    $mailto = 'aemailaddress@website.com';
    $sendersmessage = $_POST['text'];
    $fromdatabase=$_POST['datafield'];
    $subject = 'Subject sent to email';
    $sendersemail = $_POST['emailaddress'];
    $from = "From: ".$senderemail. "\n" ;
    $messageproper = "Field from database: $fromdatabase\n" . "Email of sender: $senderemail\n" . "Senders Message: $sendersmessage\n";
    mail($mailto,$subject,$messageproper,$from);
    print '
    email sent';
    }}}
    ?>[/code]
  12. Its pretty cool. Try it online. You'll see what it does. It can be modified as needed but it echo's everything always on the same exact page. Not saying its better than yours, its just interesting. Here's the version separating the html from the php.

    <?php
    if($_POST['text']=="")
    {
    ?><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><input type="text" name="text"><p><input type="submit" value="submit"></p></form>
    <?php
    }
    else
        {
    echo $_POST['text'];
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><input type="text" name="text"><p><input type="submit" value="submit"></p></form>
    <?php
    }
    ?>
  13. Hello, this cool code someone gave me. If you save this in notepad and change the email under "uncomment the following line" to your own email address. Then enter items into the fields and send. For some reason it automatically inserts your own email account into the subject field. Can anyone tell me how this cool form code does this? I need to know how it works this way so I can modify accordingly. Thanks a lot.

    <?php
      require_once 'thisform.php';
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
      <title>Forms</title>
    </head>
    <body>
    <?php
      if (isset($_POST['Submit']) &&
          isset($_POST['fieldname']) &&
          trim($_POST['fieldname']) != '' &&
          $_POST['groupname'] != '') {
        echo '<h1>Thank you for filling out this form!</h1>';
        $text = '';
        foreach ($_POST as $name => $value) {
          if (is_array($value)) {
            $text .= sprintf("%s: %s\n", $name, join(' ', $value));
          } else {
            $text .= sprintf("%s: %s\n", $name, $value);
          }
        }
    // UNCOMMENT THE FOLLOWING LINE TO USE ON YOUR SITE
      mail('youremailaddress', 'Form data', $text);
      } else {
    ?>
      <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);  ?>">
        <input type="text" name="fieldname"
          value="<?php
      echo (isset($_POST['fieldname'])) ? htmlspecialchars($_POST['fieldname']) : '';
          ?>" /><br />
        <input type="radio" name="groupname" value="php3" <?php
      if (isset($_POST['groupname']) && $_POST['groupname'] == 'php3') {
        echo 'checked="checked" ';
      }
        ?>/>PHP 3
        <input type="radio" name="groupname" value="php4" <?php
      if (isset($_POST['groupname']) && $_POST['groupname'] == 'php4') {
        echo 'checked="checked" ';
      }
        ?>/>PHP 4
        <input type="radio" name="groupname" value="php5" <?php
      if (isset($_POST['groupname']) && $_POST['groupname'] == 'php5') {
        echo 'checked="checked" ';
      }
        ?>/>PHP 5<br />
        <input type="submit" name="Submit" />
      </form>
    <?php
      }
    ?>
    </body>
    </html>

  14. OK fert, do you know how I could send the form to an email, while its looping it to the same page? For instance. How can I get the same fields to send to an email, while its showing in the echos on the same page.

    Usual email form.
    <?php
    $mailto = 'email@website.com';
    $sendfield = $_POST['sendfield']; 
    $subject = 'Email subject'; 
    $from = "From: '$sendfield'" . "\n" . 
    $messageproper = 'Field sent to this email: $sendfield\n'; 
    mail('$mailto','subject',$messageproper,$from);
    ?>

    Your modified php self code, that keeps the form fields going. How to send to an email at the same time?
    <?php
    if($_POST['text']=="")
    {
    ?><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><input type="text" name="text"><p><input type="submit" value="submit"></p></form>
    <?php
    }
    else
         {
    echo $_POST['text'];
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><input type="text" name="text"><p><input type="submit" value="submit"></p></form>
    <?php
    }
    ?>
  15. LOLOL, thanks a lot!

    Hey this might work too, maybe you can use it for something. It can probably be modified with your technique and without all the slashes.
    <?php
        if($_POST['text']=="")
        {
                   echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
                   echo "<p><input type=\"text\" name=\"text\"><p><input type=\"submit\" value=\"submit\"></p></form>";
         }
         else
         {
                  echo $_POST['text'];
                  echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
                  echo "<p><input type=\"text\" name=\"text\"><p><input type=\"submit\" value=\"submit\"></p></form>";
     
         }
    ?>
  16. Gosh good idea, I am sick of those parsing errors myself. Ok thanks for the prompts I'll study it and see if I can incorporate it into what I need. Thanks a whole lot.

    I might have a few small questions to understand better once I study fully so please check back. I really want to get my problem solved. Looks like a lot of other people are tired of the same echo problems, can't believe all the people viewing this thread.
  17. Hi, I already looked all over the web on this and still don't quite understand it.

    From what I can see $_SERVER['PHP_SELF'] is supposed to keep the same page in the browser when a form sends. If you use it in the form action= area.

    What I don't understand is usually in a form action you have to connect with what else you need the form to do. Such as sending form fields to something else. A database or an email or something. So if $_SERVER['PHP_SELF']
    takes up the form action slot, how can you send the form fields?

    Thanks a lot.
       
×
×
  • 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.