www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: Warning: Illegal string offset

  1. #16
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,519
    @ginerjm, calm down, he is a beginner, perhaps if everyone was to put what they thought was the appropriate answer, then one may speak to the OP.

    If the process was blocked in to processes:

    1. Check for a real web form ($_POST['submit'])
    2. Sanitize inputs in to a safe variable / array using a whitelist
    3. Validation of the data streams, do they contain data, if not flag it.
    4. If we pass validation: Create the email body, variables for sending the email
    5. send email and capture any send resulting from the process
    6. handle any error or success response

    That to me sums up the process involved.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  2. #17
    Join Date
    Sep 2009
    Posts
    25
    JG
    I did not mean to cause offense. I did what I thought you meant.
    There's a lot more wrong with this code, but I'll let you try it first once you get the error checking implemented.

    good luck
    I got error checking implemented.

    What the h.... is 'validationok' meant accomplish for you?
    I understood that validation is set to true
    Code:
    $validationOK=true;
    but if a field is empty then validation is false
    Code:
    if (trim($Name==""))$validationOK=false;
    if it is true an email is sent
    Code:
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    and a web page is presented
    Code:
    if ($success){
    header('Location: thank-you.html');
    exit();
    if not then an error page is presented.
    Code:
    else{
    header('Location: error-message.<html>');
    exit();
    I know I am doing something wrong and to you I am not worthy, but I try.

    I am sorry I offended you.

    thank you
    Ivanna

  3. #18
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    Yes - you have the idea to set a var to true or false in order to find out if your inputs are valid. BUT - where did you check the var to see if it was true or not?

  4. #19
    Join Date
    Sep 2009
    Posts
    25
    JG,
    if you mean how do I say it is a success or is not, that is where I am confused. I thought I had to declare a var to say it is a success. I think that is where I make mistakes.

    if $validationOK is true then it is a success. So I declare $validationOK to be $success ?

    I think I will do what you said before and start from nothing.

    again, thank you for helping.
    Ivanna

  5. #20
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    You have no idea how to program in any language, do you? The idea of testing a series of things and setting a switch ("a variable with just two values", ie, on/off, no/yes, true/false, etc.) is a perfectly valid structure that one uses to come up with a final result and provide direction as to what to do next is a commond practice. In your case you used a var called validationok and set it to false when you found an error. At the end of your series of tests though you have to do something with that variable like CHECK IT! You are not checking it. Just because you set it to false doesn't mean your program is going to react to it. YOU have to write some code to check if it is true or false and THEN do something according to that answer.

    A simple pseudo sample:

    (do some tests and set 'varok' to false when any one fails)
    (if varok == false)
    {
    create an error message saying there is a problem
    send the form and the error message back to the client
    exit
    }
    else
    {
    continue on with your script
    }

    In your code you do some tests and set a var to false but then you just go right on sending the email whether or not the var is true or false. Do you get that?

  6. #21
    Join Date
    Sep 2009
    Posts
    25
    JG
    A simple pseudo sample:
    Now I understand what you are saying to me. I will work on this.

    thank you
    Ivanna

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles