Announcement

Collapse
No announcement yet.

Calling all PHP experts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling all PHP experts

    I'm trying to get through some basic php to create a very simple website. So far I have the HTML, and the required forms from which to get with php. But, I am dealing with so many little technical errors that I feel i'm probably doing something fundamentally wrong.

    I'd be willing to paypal a few bucks for anybody willing to set-up the PHP backside and fix a few technical kinks.

    Here is the script:

    <html>

    <head>

    <php
    $to = $_REQUEST['Email'] ;
    $name = $_REQUEST['Name'];
    $subject = "A Person Has Signed Up";
    $message = "$name has signed up for {$_POST['R1']}";

    mail( "myemail.2@osu.edu", $subject, $message, "From: $to" );
    ?>

    pretty goddamn simple right? That's why its so frustrating to see this crap not working. Anyways, I'm willing to take any advice on how to make any kind of registration script.

    ps $_POST R1 is selecting a chosen radio button value
    4:BigKing> xD
    4:Best> i'm leaving chat
    4:BigKing> what did i do???
    4:Best> told you repeatedly you cannot use that emoji anymore
    4:BigKing> ???? why though
    4:Best> you're 6'4 and black...you can't use emojis like that
    4:BigKing> xD

  • #2
    please for the love of all that is holy validate your inputs before doing anything with them
    USA WORLD CHAMPS

    Comment


    • #3
      hello, my name is DROP TABLE *, nice to meet you
      The above text is a personal opinion of an individual and is not representative of the statements or opinions of Trench Wars or Trench Wars staff.

      SSCJ Distension Owner
      SSCU Trench Wars Developer


      Last edited by Shaddowknight; Today at 05:49 AM. Reason: Much racism. So hate. Such ban. Wow.

      Comment


      • #4
        nice homework
        “Imagination is more important than knowledge...”
        -Albert Einstein

        - Web / Bots Developer
        -Bots / Systems creator
        -Pub Money creator[/B]

        Comment


        • #5
          Originally posted by D1st0rt View Post
          please for the love of all that is holy validate your inputs before doing anything with them
          yeah i realized this, and did a simple $_POST on a textbox and it didn't work. If that's even what you are talking about dude. if you mean like a check for input in every box, then ya i will worry about that later. I just need a freaking email sent.

          So what do I do now, oh programming wizards? the webhost says it supports php too.
          4:BigKing> xD
          4:Best> i'm leaving chat
          4:BigKing> what did i do???
          4:Best> told you repeatedly you cannot use that emoji anymore
          4:BigKing> ???? why though
          4:Best> you're 6'4 and black...you can't use emojis like that
          4:BigKing> xD

          Comment


          • #6
            here u go

            Disregarding the fact that your should check your inputs before using them for something:

            1. make sure your input fields are name="" -d correctly,
            2. make sure you use $_POST[] for your <form></form> input information, not $_REQUEST,
            3. all the input fields need to be strings, they normally are, just saying
            4. the $message variable doesnt have to be restricted to length, but you do need a restriction to the lines of the text you have in that variable = just do
            $message = wordwrap($message, 70);

            5. make sure that for the 4th parameter, the Headers part ...
            mail('-', '-', '-', 'THIS ONE');
            you have a string, but you should have . "\r\n" at the end of that as well.
            so with your example it will be
            "From: $to"."\r\n"
            Last edited by explore; 01-15-2011, 12:52 PM.

            Comment


            • #7
              explore answered you pretty well, but I never had a problem for not using wordwrap() for my mail(). It was probably worth to do in 1995. And why you guys talk about SQL Injection where there is no SQL involved..

              First of all, check if your mail() is working :
              PHP Code:
              <?php mail('your_email@domain.com','test','test'); ?>
              If yes, the rest is a piece of cake.

              $_REQUEST is good when you don't care if you get your data from a GET or POST request. Usually, forms use the POST method. By default, forms use the GET method. So if you want POST, make sure you specify it by using the method="post" on your form anchor.

              A good habit is to always put your PHP logic on top of your file. This way, it's easier to maintain.

              Ok here is the code (not tested)

              PHP Code:
              <?php

              if (isset($_POST['submit'])) {
                  
                  
              $to $_POST['to'];
                  
              $name $_POST['name'];
                  
              $box $_POST['R1'];
                  
                  
              $subject 'A Person Has Signed Up';
                  
              $message "$name has signed up for $box";
                  
              $header "From: $to\r\n";
                  
                  
              mail('myemail.2@osu.edu'$subject $message$header);
              }

              ?>
              <html>
              <head>
                  <title>My First Form</title>
              </head>
              <body>
                  <form action="" method="post">
                      <input type="text" name="to" />
                      <input type="text" name="name" />
                      <input type="radio" tabindex="1" name="R1" value="box1" />
                      <input type="radio" tabindex="1" name="R1" value="box2" />
                      <input type="submit" name="submit" value="TROLOLOLO!" />
                  </form>
              </body>
              </html>
              Just to make sure, this script will always send your email to myemail.2@osu.edu.

              Edit: on your code, i see <php, it should be <?php. That may be the problem.
              Last edited by Arobas+; 01-15-2011, 01:31 PM.
              TW Bot Developer
              TW Web Developer
              Friends> All I saw was arobas+
              Friends> It's like death

              Comment


              • #8
                Originally posted by Arobas+ View Post
                explore answered you pretty well, but I never had a problem for not using wordwrap() for my mail(). It was probably worth to do in 1995. And why you guys talk about SQL Injection where there is no SQL involved..

                First of all, check if your mail() is working :
                PHP Code:
                <?php mail('your_email@domain.com','test','test'); ?>
                If yes, the rest is a piece of cake.

                $_REQUEST is good when you don't care if you get your data from a GET or POST request. Usually, forms use the POST method. By default, forms use the GET method. So if you want POST, make sure you specify it by using the method="post" on your form anchor.

                A good habit is to always put your PHP logic on top of your file. This way, it's easier to maintain.

                Ok here is the code (not tested)

                PHP Code:
                <?php

                if (isset($_POST['submit'])) {
                    
                    
                $to $_POST['to'];
                    
                $name $_POST['name'];
                    
                $box $_POST['R1'];
                    
                    
                $subject 'A Person Has Signed Up';
                    
                $message "$name has signed up for $box";
                    
                $header "From: $to\r\n";
                    
                    
                mail('myemail.2@osu.edu'$subject $message$header);
                }

                ?>
                <html>
                <head>
                    <title>My First Form</title>
                </head>
                <body>
                    <form action="" method="post">
                        <input type="text" name="to" />
                        <input type="text" name="name" />
                        <input type="radio" tabindex="1" name="R1" value="box1" />
                        <input type="radio" tabindex="1" name="R1" value="box2" />
                        <input type="submit" name="submit" value="TROLOLOLO!" />
                    </form>
                </body>
                </html>
                Just to make sure, this script will always send your email to myemail.2@osu.edu.

                Edit: on your code, i see <php, it should be <?php. That may be the problem.
                I will try this out soon and give updates, YOU'RE A SAINT Aro!

                Thanks for the help also explore.

                </thread> jason ..?
                4:BigKing> xD
                4:Best> i'm leaving chat
                4:BigKing> what did i do???
                4:Best> told you repeatedly you cannot use that emoji anymore
                4:BigKing> ???? why though
                4:Best> you're 6'4 and black...you can't use emojis like that
                4:BigKing> xD

                Comment


                • #9
                  pro tip:

                  http://www.w3schools.com/php/default.asp
                  The above text is a personal opinion of an individual and is not representative of the statements or opinions of Trench Wars or Trench Wars staff.

                  SSCJ Distension Owner
                  SSCU Trench Wars Developer


                  Last edited by Shaddowknight; Today at 05:49 AM. Reason: Much racism. So hate. Such ban. Wow.

                  Comment

                  Working...
                  X