Flex return value form php script

if I have a php webservice function like this
public function loginCheck($myusername, $mypassword) {
    return $rec_count;
and and Declartion like this
    <accountloginservice:AccountloginService id="accountloginService"
                                             fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                             showBusyCursor="true"
    <s:CallResponder id="loginCheckResult" />
and a button
    <s:Button id="loginButton" label="Log In" click="loginButton_clickHandler(event)"/>
and a function trigger by a button like this
protected function loginButton_clickHandler(event:MouseEvent):void {
            loginCheckResult.token = accountloginService.loginCheck(usernameLogin.text,passworkLogin.text) ;
            var check:int = parseInt(loginCheckResult.lastResult);
            if (check == 1){
why the check variable always is NULL, and how to get the value of the php script???

Please post your code for your dataGrid and your PHP or a
sample of the returned XML. Without code, it is hard to say where
the problem is, but it seems like the issue is in your
[httpService].lastResult.[blah].[blah] syntax. It helps to set a
result event for PHP calls that you then bind to your dataGrid
rather than using the lastResult method which is hard to debug:
private function phpResult(evt:ResultEvent):void {
myDataGrid.dataProvider = evt.result;
But post your code and I'm sure we can figure out the
problem.
Vygo

Similar Messages

  • How to call an Oracle Procedure and get a return value in Php

    Hi Everyone,
    Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.
    The reason why I post this here is because the ora_exec funtion is returning FALSE but the error code displayes is good. Is this a bug in the ora_exec funtion ?
    My code after the connection call is as follows:
    $cur = ora_open($this->conn);
    ora_commitoff($this->conn);
    $requestid = '144937';
    echo $requestid;
    $rc = ora_parse($cur, "begin p_ins_gsdata2
    (:requestid, :returnval); end;");
    if ($rc == true) {
    echo " Parse was successful ";
    $rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
    if ($rc2 == true) echo " Requestid Bind Successful ";
    $rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
    if ($rc3 == true) echo " Returnval Bind Successful ";
    $returnval = "0";
    $rc4 = ora_exec($cur);
    echo " Result = ".$returnval." ";
    if ($rc4 == false) {
    echo " Exec Returned FALSE ";
    echo " Error = ".ora_error($cur);
    echo " ";
    echo "ErrorCode = ".ora_errorcode($cur);
    echo "Error Executing";
    ora_close ($cur);
    The Oracle procedure has a select count from a table and it returns the number of records in that table. It's defined as:
    CREATE OR REPLACE procedure p_ins_gsdata2 (
    p_requestid IN varchar2 default null,
    p_retcode OUT varchar2)
    as
    BEGIN
    SELECT COUNT (*) INTO p_retcode
    FROM S_GSMRY_DATA_SURVEY
    WHERE request_id = p_requestid ;
    COMMIT;
    RETURN;
    END;
    Nothing much there. I want to do an insert into a table,
    from the procedure later, but I figured that I start with a select count since it's simpler.
    When I ran the Php code, I get the following:
    144937
    Parse was successful
    Requestid Bind Successful
    Returnval Bind Successful
    Result = 0
    Exec Returned FALSE
    Error = ORA-00000: normal, successful completion -- while
    processing OCI function OBNDRA
    ErrorCode = 0
    Error Executing
    I listed the messages on separate lines for clarity. I don't understand why it parses and binds o.k. but the exec returns false.
    Thanks again in advance for your help. Have a great day.
    Regards,
    Rudi

    retcode=`echo $?`is a bit convoluted. Just use:
    retcode=$?I see no EOF line terminating your input. Your flavour of Unix might not like that - it might ignore the command, though I'd be surprised (AIX doesn't).
    replace the EXEC line with :
    select 'hello' from dual;
    and see if you get some output - then you know if sqlplus commands are being called from your script. You didn't mentioned whether you see the banner for sqlplus. Copy/paste the output that you get, it will give us much more of an idea.

  • Return from a PHP Script

    Hi,
    I'm trying to get PHP and Flex to work with one another. I
    know that my program is getting the result, because if I change the
    XML to be invalid, my program will throw an error that says just
    that. However... I can't use the data that I am getting back from
    the PHP script. I have a the [httpService].lastResult.[blah].[blah]
    bound to a datagrid, but no matter what I try it isn't showing up.
    I've tried calling the httpService send() on both creationComplete
    and a button click.
    Any ideas what my problem could be? The documentation isn't
    helping me any :(

    Please post your code for your dataGrid and your PHP or a
    sample of the returned XML. Without code, it is hard to say where
    the problem is, but it seems like the issue is in your
    [httpService].lastResult.[blah].[blah] syntax. It helps to set a
    result event for PHP calls that you then bind to your dataGrid
    rather than using the lastResult method which is hard to debug:
    private function phpResult(evt:ResultEvent):void {
    myDataGrid.dataProvider = evt.result;
    But post your code and I'm sure we can figure out the
    problem.
    Vygo

  • Form PHP Script

    Hola
    Im in need of the best PHP Script form that I can get (buy)
    I got a form in one of my page, and need to "conect" to my email.
    Know a friend that he can make them so easy, but he is so hard to find, so I decide to learn how to do it.
    Now, learning PHP, maybe will be  way to much for me to learn, so I want to ask you, what PHP Script form are the most easy, better, to use.
    What --if any-- do you use?
    Thanks a lot.
    Daniel Ulysses

    Hola
    Mmm...is getting interesting...
    #1 question; Yes, Godaddy support php
    #2 question;  I watch a video about how to make one of those pages (php script) and make it how they said on the video. But...it doesn't  work.
    So, I did something wrong.
    Here is the link www.imagenpr.com
    if you go there, go to "contact us" link and you will see the form
    Even with the php script that I made for it, still doesn't work
    I'm stuck...been stuck for days
    ...need help...
    Thanks

  • Getting return value from sqlplus script while running a unix job

    I am trying to run a unix script that calls sqlplus. The following code outlines the unix/sql code that I trying to execute:
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF | grep '^RETURN_VAL' | sed 's/^RETURN_VAL//'
    SET SERVEROUTPUT ON
    VARIABLE ReturnValue NUMBER
    EXEC :ReturnValue := 1
    BEGIN
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    IF SQL%ROWCOUNT = 1 THEN
    COMMIT;
    :ReturnValue := 0;
    ELSE
    ROLLBACK;
    :ReturnValue := 99;
    END IF;
    DBMS_OUTPUT.PUT_LINE ('RETURN_VAL '||:ReturnValue);
    END;
    EXIT
    EOF`
    The above outlined sqlplus script does run because the values on the table are updated. However, I cannot get the value of ReturnValue to be displayed, so it can be returned to the unix script.
    Any ideas?

    ok do the following:-
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF
    SET SERVEROUTPUT ON
    whenever OSERROR exit 1
    whenever SQLERROR exit 2
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    EXIT
    EOF`
    rowsupdated=`echo $return_count|cut -f1 -d' '`
    echo "Rows updated =" $rowsupdated
    retcode=`echo $?`
    case "$retcode" in
    0) echo "Update executed successfully on " ;;
    1) echo "Update failed OSERROR ";;
    2) echo "Update failed SQLError " ;;
    *) echo "Update failed - Unknown Error ";;
    esac

  • How to display message when no return values in powershell script?

    Hello,
    I have written following command that returns "Failed" timer job titles for previous day :
    $FailedSPTimerJobs = Get-SPTimerJob | % { $_.HistoryEntries } | Where-Object {($_.StartTime -gt $YesterdayStartDateTime) -and ($_.To -lt $YesterdayEndDateTime) -and ($_.Status -eq 'Failed')}| Select JobDefinitionTitle | ConvertTo-Html -Fragment
    ConvertTo-Html -Body "<font color = blue><H4><B>Report </B></H4></font>$FailedSPTimerJobs " -Title "Test Report" -CssUri C:\style.CSS | Out-File "E:\Reports\Test.html"
    However, I need to display Message ( "There are no Failed Jobs recorded") when records are NULL.
    Would you please let me know how can I achieve this ?
    Thanks and Regards,
    Dipti Chhatrapati

    You could just do something like
    if ($FailedSPTimerJobs){ 
    $FailedSPTimerJobs
    = "There are no Failed Jobs recorded"
    should have been 
    if (!$FailedSPTimerJobs){ 
    $FailedSPTimerJobs
    = "There are no Failed Jobs recorded"

  • Flex application works locally, fails when online (connecting to PHP script to insert row into DB)

    Hi everyone,
    I've got a Flex application that works wonderfully when I test it on my machine locally. It uploads files and send variables to a PHP script (that inserts them into a DB) with no errors when I run it locally. As soon as I put it online, the upload continues to work but something between my Flex application and the PHP script fails because no data is committed to the DB. I know the PHP script works fine - not only does it work when I run the Flex application locally but when I go directly to the PHP file online, a new empty line is added to the DB.
    I initially thought that this was a cross domain issue so I added the following to the root of my hosted account:
    <cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*.MYURL"/>
    <allow-http-request-headers-from domain="*.MYURL" headers="*" secure="false"/>
    </cross-domain-policy>
    I based this off of what I found online which seems to have done nothing for me. I'd also be happy to provide an error message but I don't get one when I debug.
    Any thoughts would be greatly appreciated.

    Use a network monitor to see if the Flex app is truly requesting the right URL.
    -Alex

  • Another assignment, return values

    I know I have poset another unresolved problem, but that's bigger one, so I think I'll bide my time with that one. The issues with it was simply more substainsial than I thought so I guess I'm not quite ready for it... I have another assignment though, smaller one:
    I have to return values form an array that is greater than some k value, and what I'm accustomed to do, is to simply run through the array with a for-loop and if one element is greater than k, then print it out...
    However this assignment explicitly says that I should hand the array and the k value over to a method with int as return type, and that confuses me because I thought java couldn't return more than one thing at a time.
    class Main{
       public static void main( String[] args ){
          int k = -1;
          int[] array = { -3, 2, -7, 5, 4, -1, 0, -6 }
          A link = new A();
          System.out.print("The numbers greater than k are: "
                     + link.greaterNumbers( array, k );
    class A{
       public int greaterNumbers( int[] data, int k ){
       * Here I would normally just change the return type to void,
       * and print the numbers out in a for-loop, but I can't do that here.
       * So I'm unsure what to do.
       return something;
    }Edited by: kreaturen on Aug 11, 2011 5:45 PM
    Edited by: kreaturen on Aug 11, 2011 5:49 PM
    Edited by: kreaturen on Aug 11, 2011 6:08 PM

    kreaturen wrote:
    ...the return type is specified as int......but yet...
    I have to return values form an array So, even though you're new to Java you should be able to apply some common sense and reasoning here.
    On the one hand, you say you have to return an int. On the other hand, you say you have to return values. Now, even though you're a beginner, I would think you would recognize that "an int" is a single number, while "values" can encompass multiple numbers.
    You understand that much, right?
    Now my question is, how do you reconcile that discrepancy? Was one or the other just a typo? Or did you on the one hand think you have to return "an int" and on the other hand think you have to return multiple values, and just didn't notice the contradiction? Or do you just not understand the instructions? (Perhaps you're supposed to return an int representing how many values meet the criteria, rather than returning the values themselves?)
    Now you can see that before you do anything else, you must clarify the above, so that you are sure exactly what you're supposed to return and you can communicate clearly to the forum exactly what that requirement is.

  • Preventing PHP script from loading the actual page

    In my ActionScript 2 code it send the data to a php script but then loads the actual script into the browser which just shows a blank page. I don't want to load the processing script into the browser at all. How do I prevent this?
    Here's my actionscript:
    var submitListener:Object = new Object();
    submitListener.click = function(evt:Object) {
    fname2 = fname.text;
    lname2 = lname.text;
    var send_lv:LoadVars = new LoadVars();
    send_lv.fname = fname.text;
    send_lv.lname = lname.text;
    send_lv.email = email.text;
    send_lv.dept = dept.text;
    send_lv.campus = campus.text;
    send_lv.uaid = uaid.text;
    send_lv.phone = phone.text;
    send_lv.send("http://distance.uaf.edu/ferpa/process.php", "POST");
    gotoAndStop("certificate");
    submit_button.addEventListener("click", submitListener);

    create a 2nd lv instance, use the sendAndLoad() method applied to send_lv and use your 2nd lv instance as the sendAndLoad() 2nd parameter:
    var receiveLV:LoadVars=new LoadVars()
    send_lv.sendAndLoad("xxxx.php",receiveLV,"POST");
    p.s.  if you want to parse the return from your php script, use the onLoad() or onData() methods applied to receiveLV.

  • What data to return when submitting form to a php script?

    Been trying to figure this out for few days now. Been googling it up and found nothing.
    I made a form with livecycle designer, put a http submit button to post data to my php script and when I open it up on acrobat reader and try to submit it, I get an error about content-type not being correct etc.
    What kind of content-type should I be returning then? text/plain, text/html and application/pdf with 0 lenght content doesn't seem to cut it. Can I disable whole return-check as I really dont have anything to return? Or can I somehow send an "success/failure" pop-up or something?

    Thank you George,
    I added the line: header('x', TRUE, 204); to my PHP script per your suggestion and found that I get an error thrown "invalid server response" when using acrobat reader or acrobat pro 9. No new window is loaded and the pdf user's experience is not changed (except for the error message).
    Without the added line, I get the error "no input file page data" thrown.  Since I'm not returning anything to the browser that is expected but not wanted.
    In either case, the data fields are captured and saved by my PHP script. It seems that acrobat requires a response from the server otherwise it is not happy. I can't see a way that I can turn off error messages to avoid this.

  • Form/php not returning certain data

    So I just recently designed/launched a website (Dreamweaver CS 5.5) that utilizes a form for feedback from visitors. The form/corresponding php script seems to be functioning, as I have tested it numerous times. The only problem is that ONE of the entry forms doesn't seem to be returning any data.
    The HTML for the form is as follows:
      <form id="form1" name="form1" method="post" action="send.php">
            <table width="510" border="0">
              <tr>
                <td colspan="2"><p>Questions? Comments? Criticism?</p>
                <p>Let the Artist know by filling out this handy form:</p></td>
              </tr>
              <tr>
                <td width="72">Name:*</td>
                <td width="428" class="returntext"><span id="sprytextfield1">
                <label for="name"></label>
                <input type="text" name="name" id="name" />
                <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
              </tr>
              <tr>
                <td>E-Mail:*</td>
                <td class="returntext"><span id="sprytextfield2">
                <label for="email"></label>
                <input type="text" name="email" id="email" />
                <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
              </tr>
              <tr>
                <td>Subject:</td>
                <td class="returntext"><label for="textfield"></label>
                  <span id="sprytextfield3">
                  <label for="subject"></label>
                  <input type="text" name="subject" id="subject" />
                  <span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
              </tr>
              <tr>
                <td>Comment:*</td>
                <td><span id="sprytextarea1">
                  <label for="comment"></label>
                  <textarea name="comment" id="comment" cols="45" rows="5"></textarea>
    <span class="textareaRequiredMsg">A value is required.</span></span></td>
              </tr>
              <tr>
                <td> </td>
                <td><input type="submit" name="button" id="button" value="Submit" />
                <input type="reset" name="button2" id="button2" value="Reset" /></td>
              </tr>
              <tr>
                <td> </td>
                <td>Fields marked &quot;*&quot; are required.</td>
              </tr>
            </table>
          </form>
    And the PHP script is:
    <?php
    $to = "[email address removed by moderator]";
    $subject = $_REQUEST['subject'];
    $name = $_REQUEST ['name'];
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $comment = $_REQUEST['comment'] ;
    $totalmessage = "
            Name:        $name  \n
            Email:        $email  \n
            Subject:    $subject  \n
            Comment:    $comment  \n ";
    if (mail($to, $subject, $totalmessage)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
    ?>
    When I test the page through my browser (firefox 24.0), I receive the e-mail as it should be, except that the "comment" section is always empty, no matter what I enter. I have checked and double checked and triple checked, and the associated text field is names "comment", and its entry in the script is ['comment']. I have tried replacing the sprytextarea with a regular, non-spry text area, and that didn't make a difference either. The only difference between this field and the other fields (all of which are returning exactly what they should) is that it's a textarea rather than a text field...but if that is the case, I have no idea how to fix it.
    Any help on the matter would be much appreciated.

    According to the official specification for plain text email messages (http://tools.ietf.org/html/rfc2822#section-2.3), a newline character must not appear independently in the body. It should always be preceded by a carriage return.
    Your code looks like this:
    $totalmessage = "
            Name:        $name  \n
            Email:        $email  \n
            Subject:    $subject  \n
            Comment:    $comment  \n ";
    Change it to this:
    $totalmessage = "
            Name:        $name  \r\n
            Email:        $email  \r\n
            Subject:    $subject  \r\n
            Comment:    $comment";
    The specification also says that lines in the body must be no longer than 998 characters. Because you have no idea how long the content in the text area will be, it's a good idea to pass the body of the email to the wordwrap function like this before sending the mail:
    $totalmessage = wordwrap($totalmessage, "\r\n");
    I also agree with bregent that you should be using $_POST instead of $_REQUEST.

  • Return values from a popup to calling form and refresh page?

    Hi,
    Following thread Re: Popup report window from a PL/SQL proc.? I'm trying to pass the record values(checkbox + record values) to the parent windows (the retruned value is always a unique record). I was able to set the variables values with a procedure ( I vierfied in session state), but I'm unable to pass these values to the parent form and then refreshing the page. I tried the following thread without success : Refresh from Popup page
    Any hint would be appreciated.
    Thanks

    Andy,
    My page has the following query for the report region (PL/sql function):
    DECLARE
    v_string VARCHAR2(2000);
    vc VARCHAR2(2):=chr(39);
    BEGIN
    v_string:= 'SELECT '||vc||'<img src="/i//edit_big2.gif" onClick="f_payment_clrRow(this)"></img>'||vc||' Clr, '||
    ' APEX_ITEM.SELECT_LIST_FROM_QUERY(1,NULL,'||vc||'SELECT TRX_DESCRIPTION, TRX_ID FROM WTL_V_TRX_PAYMENTS WHERE TRX_EFFECT='''||V_Effect||''' '||vc||',''onchange=f_payment_trx_paymode(this); '',''NO'') Description,'||
    ' APEX_ITEM.SELECT_LIST_FROM_QUERY(2,NULL,'||vc||'SELECT DESCRIPTION, ID_VALUE FROM GEN_PR_TYPES_ENTITY '||vc||',null,''NO'') Bank,'||
    ' APEX_ITEM.TEXT(3,NULL,10,10,''ondblclick=f_callMyPopup(this);'') Document,'||
    ' APEX_ITEM.TEXT(4,NULL,10,15) Account,'||
    ' APEX_ITEM.SELECT_LIST_FROM_QUERY(5,NULL,'||vc||'SELECT ID_VALUE, ID_VALUE FROM WTL_V_TRX_CURRENCY'||vc||',''onchange=f_payment_currency_rate(this);'',''NO'') Currency,'||
    ' APEX_ITEM.TEXT(6,NULL,15,20,''onblur=f_payment_trx_amount(this); style="text-align:right;" '') Amount, '||
    ' APEX_ITEM.TEXT(7,NULL, 5, 8,''onblur=f_payment_trx_amount(this); style="text-align:right;" '') Rate, '||
    ' APEX_ITEM.TEXT(8,NULL,15,20,''readonly style="text-align:right;" '') Trx_Amount, '||
    ' APEX_ITEM.HIDDEN (9,NULL), '||
    ' APEX_ITEM.HIDDEN (10,NULL) '||
    ' from dual';
    return v_string;
    As u can see, the 3rd item uses the ondblclick to call the js function f_callMyPopup.
    My js function in the header of the page is below:
    <script>
    function f_open_lov2(page, request)
    { var url;
    url = 'f?p='+$x('pFlowId').value+':'+page+':'+$x('pInstance').value+':'+request;
    w = open(url,"winLov","Scrollbars=1,resizable=1,width=500,height=600");
    if (w.opener == null)
    w.opener = self;
    w.focus();
    function f_callMyPopup(x)
    var f01;
    var p = x.parentNode;
    while (p.tagName != "TR")
    { p = p.parentNode;}
    var inputs = p.getElementsByTagName("INPUT");
    var zz;
    for (zz = 0; zz < inputs.length; zz++)
    {if (inputs[zz].name = 'f01')
    {f01 = inputs[zz].id;}
    f_open_lov2(17,97);// I sent 97 as an example.
    </script>
    and the js in the custom popup page (17) has the following function which is executed when the user selects one of the rows using a button.
    <script>
    function f_return_value(cstring)
    opener.document.getElementById("f03").value = cstring;
    close();
    </script>
    When f_return_value is executed, the selected value is pasted in the first row of the parent page.
    Sorry , i don't know what do you mean when you say to pass the id to the custom popup page.
    Thanks again,
    Fernando
    Edited by: fnovilloes on 16/09/2009 12:01 PM
    Edited by: fnovilloes on 16/09/2009 03:56 PM
    Edited by: fnovilloes on 16/09/2009 03:59 PM

  • Call script in a workflow and get return value?

    hello
    I want create a workflow to check some attribute in IDM
    like for the home directory, use the workflow call some script to check there is enough space in the server? and the folder is almost there or not?
    then get the return value like if no enought space, call some other form let the admin input some new home directory string
    So I want to know how a workflow work with scipt file?
    I also use some after create action script, but it looks only can get some error message and shows in th IDM.

    This should help you:
    http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml
    Note that the command will be executed by the application server user so check if it has sufficient rights.
    Ben

  • Php form processing script

    Hi. I got a program to write a php form processing script. My submit form is for photo submission to my domain email. I published to site and did a test to see if it works i got this error:
    Warning: require_once(F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php): failed to open stream: No such file or directory in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24 Fatal error: require_once(): Failed opening required 'F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php' (include_path='.;C:\php\pear') in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24
    What does this mean? How can i solve this so that i can process my form?

    See if the below form helps: You need to create a folder on your server named - upload - this is where any files uploaded will be stored (make sure the folder is writable. Also change the email address where the information that someone who has uploaded a file will go to. Look for the following in the code: $to ="XXXXXXXXXXXX.com";
    <!DOCTYPE html>
    <head>
    <meta charset="UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    #wrapper {
    width: 400px;
    margin: 0 auto;
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php if(isset($_POST['submit'])) {
    $name = trim($_POST['name']);
    if(empty($name)) {
    $error['name'] = "Please provide your name";
    $location = trim($_POST['location']);
    if(empty($location)) {
    $error['location'] = "Please provide your location";
    $email = trim($_POST['email']);
    if(empty($email)) {
    $error['email'] = "Please provide your email";
    $category_description = trim($_POST['category_description']);
    if(empty($category_description)) {
    $error['category_description'] = "Please provide the category or description";
    $terms_conditions = trim($_POST['terms_conditions']);
    if(empty($terms_conditions)) {
    $error['terms_conditions'] = "Please accept the terms & conditions";
    $allowedExts = array(
       "doc",
      "docx",
            "rtf",
            "txt",
            "pdf",
            "jpeg",
            "jpg",
    $allowedMimeTypes = array(
      'application/msword',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'application/rtf',
            'application/x-rtf',
            'text/richtext',
            'text/rtf',
            'application/plain',
      'application/pdf',
      'image/gif',
      'image/jpeg',
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (empty($_FILES["file"]["name"])) {
        $selectFile = 'Please select a file to upload';
    elseif ( ! ( in_array($extension, $allowedExts ) ) ) {
      $fileTypeNotAllowed = 'File type not allowed';
    elseif ($_FILES["file"]["size"] > 2097152) {
      $fileTooLarge = 'Please provide a smaller file';
    elseif (file_exists("upload/" . $_FILES["file"]["name"])) {
    $fileExists = $_FILES["file"]["name"] . " already exists, Please change the file name ";
    elseif (in_array( $_FILES["file"]["type"], $allowedMimeTypes ) )
        if(!empty($_POST['terms_conditions'])) {
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
        $fileName = $_FILES["file"]["name"];
        $fileUploadSuccessful = 'File uploaded successfully';
    $to = "XXXXXXXXXXXXX.com";
    $subject   = "Upload to website";
    $headers  = "From: $email\r\n";
    $headers .= "Reply-To: $email\r\n";
    $message = "Name: $name\n\n";
    $message .= "Location: $location\n\n";
    $message .= "Email Address: $email\n\n";
    $message .= "Category/Description: $category_description\n\n";
    $message .= "File: $fileName\n\n";
    mail($to, $subject, $message, $headers);
    $sent = "Mail was sent successfully";
    ?>
    <h1>Form</h1>
    <?php
    foreach ($error as $value) {
        echo "<p>".$value."</p>";
    if(isset($formFieldError)) {
    echo "<p>".$formFieldError."</p>";
    if(isset($selectFile)) {
    echo "<p>".$selectFile."</p>";
    if(isset($fileTypeNotAllowed)) {
    echo "<p>".$fileTypeNotAllowed."</p>";
    if(isset($fileTooLarge)) {
    echo "<p>".$fileTooLarge."</p>";
    if(isset($fileExists)) {
    echo "<p>".$fileExists."</p>";
    if(isset($fileUploadSuccessful)) {
    echo "<p>".$fileUploadSuccessful."</p>";
    ?>
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <p>
    <label for="name">Name<br>
    <input type="text" name="name" id="name" value="<?php if(isset($name)) {echo $name; }  ?>"/>
    </label>
    </p>
    <p>
    <label for="location">Location<br>
    <input type="text" name="location" id="location" value="<?php if(isset($location)) {echo $location; }  ?>"/>
    </label>
    </p>
    <p>
    <label for="email">Email<br>
    <input type="text" name="email" id="email" value="<?php if(isset($email)) {echo $email; }  ?>" />
    </label>
    </p>
    <p>
    <label for="category_description">Category and Description<br>
    <input type="text" name="category_description" id="category_description" value="<?php if(isset($category_description)) {echo $category_description; }  ?>" />
    </label>
    </p>
    <p>
    <label for="file">File Attachment:<br>
    <input type="file" name="file" id="file" />
    </label>
    </p>
    <p>
    <label for="terms_conditions">Terms & Conditions:
    <input name="terms_conditions" type="checkbox" value="accept" <?php if(isset($_POST['terms_conditions'])) {echo "checked"; }  ?>> (Please check)
    </label>
    </p>
    <input type="submit" name="submit" value="Submit" />
    </form>
    </div>
    </body>
    </html>

  • Trouble with the header content of php script - return wrong character: ?�?

    Hello everybody!
    I have one problem with reading of content of php's return text value.
    Ok in php script was programmed something like this:
    ===========================================
         $new1 = ereg_replace(".*OUTPUT url=\"(.{40,70})\" ?/>.*", "\\1",$XMLResponse);
         $size = strlen($new1);
         header("Content-Type: text/plain");
         header("Content-Length: " .$size);
         echo $new1;
    ==========================================
    $new1 includes url address to picture.
    Ok, in my java applet I'm using the method readLine() of DataInputStream Class, where I'm reading the return text value of the mentioned php script. The code is here:
    ==========================================
              try {
                   dis = new DataInputStream(url.openStream());
                   str = dis.readLine();
              } catch (IOException e2) {
    ==========================================
    but response is a text plus this kind of characters in beginning : ?�?
    What the trouble there? Thank you
    Jan Zitniak :)

    Hello,
    thank you for your idea, but I resolved problem with this code:
              URL urlReal = null;
              try {
                   urlReal = new URL (str); // convert String to URL
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    In that code I "converted" a string to url where the string happened a real URL address.
    Jan :)

Maybe you are looking for

  • Now that iBiz is not compatible with Mavericks, what type of accounting software works with ical.

    I use iBiz for a small business that tracks appointments and expenses.  I don't need payroll.  Most importantly, I need the software to communicate with calendar since I have to keep my partner's calendar up to date and he uses calendar on his iphone

  • Accounting entry Inter company issue of goods as Sample

    Dear SAP expert We have a process to issue Finshed goods to vendor for testing purpose. For this, I am issuing a finished goods for testing purpose to vendor (another company code  in same group) . At that stage accounting entry for goods issue is Co

  • Traffic Shaping - can't get it to work

    Hi I'm attempting to create a basic traffic shaping policy in a lab environment but I can't seem to get it to limit the download rate? I can successfully achieve this with policing. I am testing the speed restriction using a broadband speed testing w

  • Problem with pages containing Facebook links

    At the school where I teach, Facebook and other social networking sites are blocked by the school's server. Any time I open a web page in Safari containing a link to Facebook, I get a pop-up, which I immediately dismiss. This can happen dozens of tim

  • Error Connecting to SAP server via JCO

    Hi,   When i tried to connect SAP server using JCO its giving error "Fatal error User name or password incorrect" .But with the same username and password i'm able to login to the SAP system with SAP logon pad. My username contains only numeric,does