Jump to content

dc_jt

Members
  • Posts

    290
  • Joined

  • Last visited

    Never

Posts posted by dc_jt

  1. [quote author=fiddy link=topic=113709.msg462332#msg462332 date=1162550426]
    Can you pls try this:

    (if($_REQUEST['photo']=="" && $_REQUEST['memory']=="" && $_REQUEST['datap']==""){)
    [/quote]

    That works for the memory part but not for the photo!

    Have a look at my above post, thats how you get the photo part working but i cant put them together now ha

    ??
  2. I have got it working for photo now by doing:

    [quote]if($_FILES['photo']['error'] != UPLOAD_ERR_OK){$_REQUEST[errors]['Optional']='<div class="errors">Please enter either a photo or a memory</div>';}[/quote]

    However, i need to put the or memory bit in somewhere.

    I tried

    [quote]if($_FILES['photo']['error'] != UPLOAD_ERR_OK || !$_REQUEST['memory']{$_REQUEST[errors]['Optional']='<div class="errors">Please enter either a photo or a memory</div>';}[/quote]

    But then neither would work

    ??
  3. It doesnt matter about the datap now, thats not required its just the photo and memory.

    i tried this:

    [quote]if(!$_REQUEST['memory'] || !$_FILES['photo']){$_REQUEST[errors]['gukhk']='<div class="errors">Please enter either a photo or a memory</div>';}[/quote]

    And that works, so if memory is only inserted thats fine, however if just a photo is inserted, it still throw the error message.

    Any idea?

    Thanks
  4. Hi

    I have a form which contains fields such as name, email, photo etc.

    If someone does not enter a required field such as a name or email then they are returned back to the form with the error messages displayed.

    When the form is refreshed, every input they entered is still there by using [quote]<H4><input name="email" type="text" value="<?=htmlentities(stripslashes($_POST['email']))?>" SIZE=50/>[/quote] for example.

    The only one that doesnt is the photo field. Any idea how to keep hold of the photo input field when the form is refreshed?

    Below is the code for my form

    Thanks

    [quote]<form enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF']?>" method="post">
    </center><BLOCKQUOTE><center><P><TABLE BORDER=0 CELLSPACING=0>
    <TR>
    <TD WIDTH=116>
    <H4>Name:</H4>
    </TD><TD>
    <H4><input name="name" type="text" value="<?=htmlentities(stripslashes($_POST['name']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Address:</H4>
    </TD><TD>
    <H4><input name="address1" type="text" value="<?=htmlentities(stripslashes($_POST['address1']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Town:</H4>
    </TD><TD>
    <H4><input name="town" type="text" value="<?=htmlentities(stripslashes($_POST['town']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>City:</H4>
    </TD><TD>
    <H4><input name="city" type="text" value="<?=htmlentities(stripslashes($_POST['city']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Post Code/Zip Code:</H4>
    </TD><TD>
    <H4><input name="postcode" type="text" value="<?=htmlentities(stripslashes($_POST['postcode']))?>"/></H4>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Country:</H4>
    </TD><TD>
    <H4>
    <select name="country">
            <option value="United Kingdom">United Kingdom</option>
            <option value="United States of America">United States of America</option>
            <option value="Spain">Spain</option>
            <option value="Italy">Italy</option>
          </select>
    <TR>
    <TD WIDTH=116>
    <H4>Email Address:</H4>
    </TD><TD>
    <H4><input name="email" type="text" value="<?=htmlentities(stripslashes($_POST['email']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>I agree to grant a license for you to use my text/photograph</H4>
    </TD><TD>
    <H4><input name="license" type="checkbox" id="license" value="1" <?=($_POST['license'] == '1')?' checked="checked"':''?>/></H4>
    <TR>
    <TD WIDTH=116>
    <H4>Photo:</H4>
    </TD><TD>
    <H4><input type="file" name="photo" ></H4>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Memory:</H4>
    </TD><TD>
    <H4><textarea name="memory" rows=6 cols=40 id="memory"><?=($_POST['memory'])?></textarea></textarea></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>Data Protection:</H4>
    </TD><TD>
    <H4><input name="datap" type="checkbox" id="datap" value="1" <?=($_POST['datap'] == '1')?' checked="checked"':''?>/></H4>


    <br class="clear"/>
    <input type="Submit" name="submit" value="Submit"  class="button"/>
      <input type="hidden" name="mode" value="apply" />
    <?php }//end else?>[/quote]
  5. I have a form with fields which must be required such as name, address, town, city etc.

    I then need to have a photo, a memory field and a data protection tick box, for which at least one must be selected.

    I tried this but it only works for the memory field and the data protection. If a user only chooses to insert a photo the error still occurs.

    [quote]if($_REQUEST[mode]=="apply"){
    //error checking here

    if(!$_REQUEST['name']){$_REQUEST[errors]['Name']='<div class="errors">Please enter your Name</div>';}
    if(!$_REQUEST['address1']){$_REQUEST[errors]['Address']='<div class="errors">Please enter your Address</div>';}
    if(!$_REQUEST['town']){$_REQUEST[errors]['Town']='<div class="errors">Please enter your Town</div>';}
    if(!$_REQUEST['city']){$_REQUEST[errors]['City']='<div class="errors">Please enter your City</div>';}
    if(!$_REQUEST['postcode']){$_REQUEST[errors]['Postcode']='<div class="errors">Please enter your Postcode</div>';}
    if(!$_REQUEST['country']){$_REQUEST[errors]['Country']='<div class="errors">Please enter your Country</div>';}
    if(!$_REQUEST['license']){$_REQUEST[errors]['License']='<div class="errors">Please agree to grant a license for the use of your text/photo</div>';}
    if(!$_REQUEST['photo']!="" && !$_REQUEST['memory']!="" && !$_REQUEST['datap']!=""){$_REQUEST[errors]['Optional']='<div class="errors">Please either enter a photo, memory or agree to the Data Protection Act</div>';}
    if(validateemail($_REQUEST['email'])===false){$_REQUEST[errors]['Email']='<div class="errors">Please enter a valid Email address</div>';}
    [/quote]

    I think it might have something to do with the [quote]if(!$_REQUEST['photo']!="" [/quote]

    I tried using [quote]if(!$_FILES['photo']!="" [/quote] but the rror doesnt come up at all then.

    Any ideas??

    Thanks
  6. I have form which emails details input by user.

    I have a field which uploads an image, but i need this to be attached to my email.

    The code for my email at the moment is:

    [code]
    //send email
    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $address=$_REQUEST['address1'];
    $town=$_REQUEST['town'];
    $city=$_REQUEST['city'];
    $postcode=$_REQUEST['postcode'];
    $country=$_REQUEST['country'];
    $license=$_REQUEST['license'];
    $memory=$_REQUEST['memory'];
    $photo=$_FILES['photo'];
    $datap=$_REQUEST['datap'];

    $to      = "***@***.com";
    $subject = "Readers Archive";
    $message = 'Name: ' .$name."\n". 'Email: '.$email."\n". 'Address: '.$address."\n". 'Town: '.$town."\n". 'City: '.$city."\n".'Postcode:'.$postcode."\n".'Country: '.$country."\n".'Photo:'.$photo;

    $from =  'From: ***@***.com';
    mail($to, $subject, $message, $from);
    mail("***@***.com", $subject, $message, $from);


    }
    }
    ?>
    [/code]

    This successfuly emails all user details. So how could i attach the actual photo to this?? (At the moment is just says 'Array' next to the photo part in the email.

    Thanks
  7. Anyone pleeeease???

    Ive been looking over this for about 3 hours and cant find the explanation??

    Im getting no value inserted into the photo field and no photos (images) are being uploaded??

    Everything else is being inserted into database correctly, its just the photo field.

    Thanks again
  8. Been playing around with it, I had it working then I cocked it up again somehow. Dont think I change any of the photo bit tho.

    Can anyone see where Im going wrong?

    Here is my index.php

    [quote]<?php
    require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php');
    require_once(LOCAL_CLASSES.'/Tables/RCLTblReaders.class.php');
    require_once(GLOBALS.'global_fns.php');


    $oTblReaders = new RCLTblReaders();

    if($_REQUEST[mode]=="apply"){
    //error checking here

    if(!$_REQUEST['name']){$_REQUEST[errors]['Name']='<div class="errors">Please enter your Name</div>';}
    if(!$_REQUEST['address1']){$_REQUEST[errors]['Address']='<div class="errors">Please enter your Address</div>';}
    if(!$_REQUEST['town']){$_REQUEST[errors]['Town']='<div class="errors">Please enter your Town</div>';}
    if(!$_REQUEST['city']){$_REQUEST[errors]['City']='<div class="errors">Please enter your City</div>';}
    if(!$_REQUEST['postcode']){$_REQUEST[errors]['Postcode']='<div class="errors">Please enter your Postcode</div>';}
    if(!$_REQUEST['country']){$_REQUEST[errors]['Country']='<div class="errors">Please enter your Country</div>';}
    if(!$_REQUEST['license']){$_REQUEST[errors]['License']='<div class="errors">Please agree to grant a license for the use of your text/photo</div>';}
    if(!$_REQUEST['photo']!="" && !$_REQUEST['memory']!="" && !$_REQUEST['datap']!=""){$_REQUEST[errors]['Optional']='<div class="errors">Please either enter a photo, memory or agree to the Data Protection Act</div>';}
    if(validateemail($_REQUEST['email'])===false){$_REQUEST[errors]['Email']='<div class="errors">Please enter a valid Email address</div>';}

    $sEmail = $_REQUEST['email'];
    $iDuplicate = $oTblReaders->DuplicateEmail($sEmail);

    if(sizeof($_REQUEST['errors'])<1)
    //if no errors then execute application
    {
    //if no errors then execute.


    if(isset($_FILES['photo']))
    {
    if($_FILES['photo']['error'] != UPLOAD_ERR_OK)
    {
    print("A correct filename is needed a png, jpg or gif! <br />");
    }
    else{
    $sFileName = $_FILES['photo']['name'];
    move_uploaded_file($_FILES['photo']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/uploads'.$sFileName);
    echo "Name: ".$_FILES['photo']['name']."<br />";
            echo "Size: ".$_FILES['photo']['size']."<br />";
            echo "Type: ".$_FILES['photo']['type']."<br />";
            echo "Photo Uploaded Successfully<br />";

    }
    }
      if($iDuplicate != 0)
    {
    echo 'please choose a different email this one is already stored in the database';
    }
    else{
    $oTblReaders->AddReader($_POST, $sFileName);
    $_REQUEST['mode']="complete";
        }
    //send email
    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $address=$_REQUEST['address1'];
    $town=$_REQUEST['town'];
    $city=$_REQUEST['city'];
    $postcode=$_REQUEST['postcode'];
    $country=$_REQUEST['country'];
    $license=$_REQUEST['license'];
    $memory=$_REQUEST['memory'];
    $photo=$_FILES['photo'];
    $datap=$_REQUEST['datap'];

    $to      = "liverpool@liverpooltest.com";
    $subject = "Readers Archive";
    $message = 'Name: ' .$name."\n". 'Email: '.$email."\n". 'Address: '.$address."\n". 'Town: '.$town."\n". 'City: '.$city."\n".'Postcode:'.$postcode."\n".'Country: '.$country."\n".'Photo:'.$photo;

    $from =  'From: website@liverpooltest.com';
    mail($to, $subject, $message, $from);
    mail("---@---", $subject, $message, $from);


    }
    }
    ?>

    <?php
    if ($_REQUEST['mode'] == 'complete')
    {
    echo '<div class="complete">Thank You for submitting your details.</div>';

    }
    else
    {
    ?>

    <? if($_REQUEST[errors]){
    ?>

    <ul>
    <?
    foreach($_REQUEST[errors] as $error){echo $error;}
    ?></ul><?
    }
    ?>

    <form name="myform" method="post" action="<?=$_SERVER['PHP_SELF']?>">
    </center><BLOCKQUOTE><center><P><TABLE BORDER=0 CELLSPACING=0>
    <TR>
    <TD WIDTH=116>
    <H4>Name:</H4>
    </TD><TD>
    <H4><input name="name" type="text" value="<?=htmlentities(stripslashes($_POST['name']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Address:</H4>
    </TD><TD>
    <H4><input name="address1" type="text" value="<?=htmlentities(stripslashes($_POST['address1']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Town:</H4>
    </TD><TD>
    <H4><input name="town" type="text" value="<?=htmlentities(stripslashes($_POST['town']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>City:</H4>
    </TD><TD>
    <H4><input name="city" type="text" value="<?=htmlentities(stripslashes($_POST['city']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Post Code/Zip Code:</H4>
    </TD><TD>
    <H4><input name="postcode" type="text" value="<?=htmlentities(stripslashes($_POST['postcode']))?>"/></H4>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Country:</H4>
    </TD><TD>
    <H4>
    <select name="country">
            <option value="United Kingdom">United Kingdom</option>
            <option value="United States of America">United States of America</option>
            <option value="Spain">Spain</option>
            <option value="Italy">Italy</option>
          </select>
    <TR>
    <TD WIDTH=116>
    <H4>Email Address:</H4>
    </TD><TD>
    <H4><input name="email" type="text" value="<?=htmlentities(stripslashes($_POST['email']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>I agree to grant a license for you to use my text/photograph</H4>
    </TD><TD>
    <H4><input name="license" type="checkbox" id="license" value="1" <?=($_REQUEST['license'] == '1')?' checked="checked"':''?>/></H4>
    <TR>
    <TD WIDTH=116>
    <H4>Photo:</H4>
    </TD><TD>
    <H4><input type="file" name="photo" ></H4>
    <br>

    <TR>
    <TD WIDTH=116>
    <H4>Memory:</H4>
    </TD><TD>
    <H4><textarea name="memory" rows=6 cols=40 id="memory"><?=($_POST['memory'])?></textarea></textarea></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>Data Protection:</H4>
    </TD><TD>
    <H4><input name="datap" type="checkbox" id="datap" value="1" <?=($_REQUEST['datap'] == '1')?' checked="checked"':''?>/></H4>


    <br class="clear"/>
    <input type="Submit" name="submit" value="Submit"  class="button"/>
      <input type="hidden" name="mode" value="apply" />
    <?php }//end else?>[/quote]

    And here is my RCTblReaders.class.php

    [quote]<?php

    require_once(LOCAL_CLASSES.'/RCLDbBase.class.php');
    require_once(GLOBALS.'global_fns.php');


    class RCLTblReaders extends RCLDbBase
    {
    protected $sTableName = "readers";

    public function AddReader($aPost, $sFileName)
    {


    $sSql = "INSERT INTO readers SET
    `name`='".$aPost['name']."',
    `email`='".$aPost['email']."',
    `address`='".$aPost['address1']."',
    `town`='".$aPost['town']."',
    `city`='".$aPost['city']."',
    `postcode`='".$aPost['postcode']."',
    `country`='".$aPost['country']."',
    `license`='".$aPost['license']."',
    `memory`='".$aPost['memory']."',
    `datap`='".$aPost['datap']."',
    `photo`='$sFileName' ";

    //print $sSql;


    return mysql_query($sSql, $this->oDb->GetConnection());
    }
    public function DuplicateEmail($sEmail)
    {
    $sSql = "SELECT COUNT(reader_id) AS num FROM readers WHERE email = '$sEmail' ";

    return mysql_result(mysql_query($sSql, $this->oDb->GetConnection()), 0, 'num');
    }
    }

    ?>[/quote]

    Any help is much appreciated

    Thanks
  9. This is the full index.php

    [quote]<?php
    require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php');
    require_once(LOCAL_CLASSES.'/Tables/RCLTblReaders.class.php');
    require_once(GLOBALS.'global_fns.php');

    if($_REQUEST[mode]=="apply"){
    //error checking here

    if(!$_REQUEST['name']){$_REQUEST[errors]['Name']='<div class="errors">Please enter your Name</div>';}
    if(!$_REQUEST['address1']){$_REQUEST[errors]['Address']='<div class="errors">Please enter your Address</div>';}
    if(!$_REQUEST['town']){$_REQUEST[errors]['Town']='<div class="errors">Please enter your Town</div>';}
    if(!$_REQUEST['city']){$_REQUEST[errors]['City']='<div class="errors">Please enter your City</div>';}
    if(!$_REQUEST['postcode']){$_REQUEST[errors]['Postcode']='<div class="errors">Please enter your Postcode</div>';}
    if(!$_REQUEST['country']){$_REQUEST[errors]['Country']='<div class="errors">Please enter your Country</div>';}
    if(!$_REQUEST['license']){$_REQUEST[errors]['License']='<div class="errors">Please agree to grant a license for the use of your text/photo</div>';}
    if(!$_REQUEST['photo']!="" && !$_REQUEST['memory']!="" && !$_REQUEST['datap']!=""){$_REQUEST[errors]['Optional']='<div class="errors">Please either enter a photo, memory or agree to the Data Protection Act</div>';}
    if(validateemail($_REQUEST['email'])===false){$_REQUEST[errors]['Email']='<div class="errors">Please enter a valid Email address</div>';}


    if(sizeof($_REQUEST[errors])<1)
    {
    //if no errors then execute application

    $oReaders = new RCLTblReaders();
    if (!$oReaders->AddReader($_POST))
    {
    $_REQUEST['errors']['db'] = 'Please check your details again</div>';
    }
    $_REQUEST[mode]="complete";

    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $address=$_REQUEST['address1'];
    $town=$_REQUEST['town'];
    $city=$_REQUEST['city'];
    $postcode=$_REQUEST['postcode'];
    $country=$_REQUEST['country'];
    $license=$_REQUEST['license'];
    $memory=$_REQUEST['memory'];
    $photo=$_REQUEST['photo'];
    $datap=$_REQUEST['datap'];

    $to      = "liverpool@liverpooltest.com";
    $subject = "Readers Archive";
    $message = 'Name: ' .$name."\n". 'Email: '.$email."\n". 'Address: '.$address."\n". 'Town: '.$town."\n". 'City: '.$city."\n".'Postcode:'.$postcode."\n".'Country: '.$country."\n".'Photo:'.$photo;

    $from =  'From: website@liverpooltest.com';
    mail($to, $subject, $message, $from);
    mail("----@----", $subject, $message, $from);


    }
    }
    ?>
    <?php
    if ($_REQUEST['mode'] == 'complete')
    {
    echo 'Thank You for submitting your details.';

    }
    else
    {
    ?>

    <? if($_REQUEST[errors]){
    ?>

    <ul>
    <?
    foreach($_REQUEST[errors] as $error){echo $error;}
    ?></ul><?
    }
    ?>
    <form name="myform" method="post" action="<?=$_SERVER['PHP_SELF']?>">


    </center><BLOCKQUOTE><center><P><TABLE BORDER=0 CELLSPACING=0>
    <TR>
    <TD WIDTH=116>
    <H4>Name:</H4>
    </TD><TD>
    <H4><input name="name" type="text" value="<?=htmlentities(stripslashes($_POST['name']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Address:</H4>
    </TD><TD>
    <H4><input name="address1" type="text" value="<?=htmlentities(stripslashes($_POST['address1']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Town:</H4>
    </TD><TD>
    <H4><input name="town" type="text" value="<?=htmlentities(stripslashes($_POST['town']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>City:</H4>
    </TD><TD>
    <H4><input name="city" type="text" value="<?=htmlentities(stripslashes($_POST['city']))?>" SIZE=50/>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Post Code/Zip Code:</H4>
    </TD><TD>
    <H4><input name="postcode" type="text" value="<?=htmlentities(stripslashes($_POST['postcode']))?>"/></H4>
    <br class="clear"/>
    </TD></TR>
    <TR>
    <TD WIDTH=116>
    <H4>Country:</H4>
    </TD><TD>
    <H4>
    <select name="country">
            <option value="United Kingdom">United Kingdom</option>
            <option value="United States of America">United States of America</option>
            <option value="Spain">Spain</option>
            <option value="Italy">Italy</option>
          </select>
    <TR>
    <TD WIDTH=116>
    <H4>Email Address:</H4>
    </TD><TD>
    <H4><input name="email" type="text" value="<?=htmlentities(stripslashes($_POST['email']))?>" SIZE=50/>
    <br class="clear"/></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>I agree to grant a license for you to use my text/photograph</H4>
    </TD><TD>
    <H4><input name="license" type="checkbox" id="license" value="1" <?=($_REQUEST['license'] == '1')?' checked="checked"':''?>/></H4>
    <TR>
    <TD WIDTH=116>
    <H4>Photo:</H4>
    </TD><TD>
    <H4><input type="file" name="photo"></H4>
    <br>
    <?
    if(isset( $Submit ))
    {
    //If the Submitbutton was pressed do:

    if ($_FILES['photo']['type'] == "image/gif"){
    copy ($_FILES['photo']['tmp_name'], "uploads/".$_FILES['photo']['name'])
        or die ("Could not copy");
    }
    }
    ?>

    <TR>
    <TD WIDTH=116>
    <H4>Memory:</H4>
    </TD><TD>
    <H4><textarea NAME="memory" VALUE="<?=htmlentities(stripslashes($_POST['memory']))?>" rows=6 cols=40></textarea></H4>
    </TD></TR>
    <TR>
    <TD WIDTH=210>
    <H4>Data Protection:</H4>
    </TD><TD>
    <H4><input name="datap" type="checkbox" id="datap" value="1" <?=($_REQUEST['datap'] == '1')?' checked="checked"':''?>/></H4>


    <br class="clear"/>
    <input type="Submit" name="submit" value="Submit"  class="button"/>
      <input type="hidden" name="mode" value="apply" />
    <?php }//end else?>[/quote]

    And a class called Readers.class.php

    [quote]<?php

    require_once(LOCAL_CLASSES.'/RCLDbBase.class.php');
    require_once(GLOBALS.'global_fns.php');


    class RCLTblReaders extends RCLDbBase
    {
    protected $sTableName = "readers";

    public function AddReader($aPostData)
    {


    $sSql = "INSERT INTO readers SET `name`='".$aPostData['name']."', `email`='".$aPostData['email']."',
    `address`='".$aPostData['address1']."', `town`='".$aPostData['town']."', `city`='".$aPostData['city']."', `postcode`='".$aPostData['postcode']."',
    `country`='".$aPostData['country']."', `license`='".$aPostData['license']."', `memory`='".$aPostData['memory']."', `photo`='".$aPostData['photo']."', `datap`='".$aPostData['datap']."'";

    //print $sSql;


    return mysql_query($sSql, $this->oDb->GetConnection());
    }

    }
    ?>[/quote]
  10. Im trying to upload an image from a form.

    Got something like this, but the images dont appear in the uploads folder which is in the route directory.

    [quote]<H4>Photo:</H4>
    </TD><TD>
    <H4><input type="file" name="photo"></H4>
    <br>
    <?
    if(isset( $Submit ))
    {
    if($_FILES['photo']['error'] ==UPLOAD_ERR_OK)
    {
    $sImgFileName = $_FILES['photo']['name'].time();
    if (move_uploaded_file($_FILES['photo']['tmp_name'], UPLOADS_PATH.'/'.$sImgFileName))
    {


    }
    }
    }
    ?>[/quote]

    Any help??
  11. Hi

    I
    have a form which when submitted is emailed to a certain email address. However I would like to attach the image which is submitted from the user to the email but havent got a clue how.

    Anyone know how i put it into my email code?

    Thanks


    [code]if(sizeof($_REQUEST[errors])<1)
    {
    //if no errors then execute application

    $oReaders = new RCLTblReaders();
    if (!$oReaders->AddReader($_POST))
    {
    $_REQUEST['errors']['db'] = 'Please check your details again</div>';
    }
    $_REQUEST[mode]="complete";



    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $address=$_REQUEST['address1'];
    $town=$_REQUEST['town'];
    $city=$_REQUEST['city'];
    $postcode=$_REQUEST['postcode'];
    $country=$_REQUEST['country'];
    $license=$_REQUEST['license'];
    $memory=$_REQUEST['memory'];
    $photo=$_REQUEST['photo'];
    $datap=$_REQUEST['datap'];

    $to      = "***@***.com";
    $subject = "Readers Archive";
    $message = 'Name: ' .$name."\n". 'Email: '.$email."\n". 'Address: '.$address."\n". 'Town: '.$town."\n". 'City: '.$city."\n".'Postcode:'.$postcode."\n".'Country: '.$country."\n".'Photo:'.$photo;

    $from =  'From: ***@***.com';
    mail($to, $subject, $message, $from);
    mail("***@***.com", $subject, $message, $from);


    }
    }
    ?>
    <?php
    if ($_REQUEST['mode'] == 'complete')
    {
    echo 'Thank You for submitting your details.';

    }
    else
    {
    ?>

    <? if($_REQUEST[errors]){
    ?>

    <ul>
    <?
    foreach($_REQUEST[errors] as $error){echo $error;}
    ?>[/code]
  12. Used this

    if(!$_REQUEST['photo']!="" || !$_REQUEST['memory']!="" || !$_REQUEST['datap']!=""){$_REQUEST[errors]['Optional']='<div class="errors">Please either enter a photo, memory or agree to the Data Protection Act</div>';}

    And when none of the three were entered the error message came up which is correct.

    However, when one was entered it still came up. Therefore, the error only comes up when all three are not entered.

    Does that make sense??

    Thanks
  13. I have a form with required fields to be
    Name
    Address
    Town
    City
    Postcode
    license
    valid Email address

    I then have three optional fields, photo, memory and data protection.

    I have done the error checking for the required fields, however out of the three optional fields AT LEAST ONE must be entered.

    I tried using the || but doesnt seem to work.

    Any ideas??

    if($_REQUEST[mode]=="apply"){
    //error checking here

    if(!$_REQUEST['name']){$_REQUEST[errors]['Name']='<div class="errors">Please enter your Name</div>';}
    if(!$_REQUEST['address1']){$_REQUEST[errors]['Address']='<div class="errors">Please enter your Address</div>';}
    if(!$_REQUEST['town']){$_REQUEST[errors]['Town']='<div class="errors">Please enter your Town</div>';}
    if(!$_REQUEST['city']){$_REQUEST[errors]['City']='<div class="errors">Please enter your City</div>';}
    if(!$_REQUEST['postcode']){$_REQUEST[errors]['Postcode']='<div class="errors">Please enter your Postcode</div>';}
    if(!$_REQUEST['country']){$_REQUEST[errors]['Country']='<div class="errors">Please enter your Country</div>';}
    if(!$_REQUEST['license']){$_REQUEST[errors]['License']='<div class="errors">Please agree to grant a license for the use of  your text/photo</div>';}
    [b]if(!$_REQUEST['photo'] || !$_REQUEST['memory'] || !$_REQUEST['datap']){$_REQUEST[errors]['Photo']='<div class="errors">Please either enter a photo, memory or agree to the Data Protection Act</div>';}[/b] if(validateemail($_REQUEST['email'])===false){$_REQUEST[errors]['Email']='<div class="errors">Please enter a valid Email address</div>';}


    if(sizeof($_REQUEST[errors])<1)
    {
  14. Hi I have a form with

    <H4>Country:</H4>
    </TD><TD>
    <H4>
    <SELECT NAME="country">
    <OPTION VALUE='United Kingdom' >United Kingdom
    <OPTION VALUE='United States of America' >United States of America
    <OPTION VALUE='Spain' >Spain
    <OPTION VALUE='Italy' >Italy
    </SELECT>

    When United Kingdom is selected, it is displayed and saved in the database as United and not United Kingdom. The same with USA.

    Any ideas why?

    Thanks
  15. Im using self.history.back function to go back from one form to another.

    This works perfectly fine with Firefox but not with IE.

    Any ideas why?

    (I tried to post code but it wouldnt let me) The back button is this tho:

    [code]} // end foreach
    ?><br /><input class="databut" type="button" value="Back" onClick='self.history.back();'></ul><?
    } //end if (is_array($aErrors)...
    else {
    ?> [/code]
  16. My mistake I posted the wrong global above. Here is the correct one:

    [code]function validate_email ($email)
    {
    if(preg_match('^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*$', $email))
    {
    return true;
    }
      else
    {
        return false;
    }
    }

    function validateemail ($email)
    {
    return validate_email($email);

    function validate_name ($name)
    {
    if(ereg("/^[a-zA-Z\-\Ä\ä\Ö\ö\Ü\ü\s]+$/s", $name))
    {
    return true;
    }
      else
    {
        return false;
    }

    }
    function validatename ($name)
    {
    return validate_name($name);[/code]

    So I do have a validatename function
  17. [code]<?php

    require_once(LOCAL_CLASSES.'/RCLDbBase.class.php');
    require_once(GLOBALS.'global_fns.php');

    class RCLTblClients extends RCLDbBase

    {
    protected $sTableName = "clients";

    public function AddClient($aPostData)
    {
    $aReturn = $this->ValidateClientData($aPostData);

    if (!$aReturn[0])
    {
    return $aReturn;
    }

    $sSql = "INSERT INTO $this->sTableName SET
    name = '$aPostData[Name]',
    email = '$aPostData[Email]',
    address = '$aPostData[Address]',
    business_name = '$aPostData[Business_Name]',
    type_of_business = '$aPostData[Type_of_Business]',
    comments ='$aPostData[Comments]' ";

    return array(mysql_query($sSql, $this->oDb->GetConnection()));
    }

    private function ValidateClientData($aPostData)
    {
    $aErrors = array();

    if(validatename($aPostData['Name'])===false)
    {
    $aErrors['Name']='Please enter your Name';}

    if(validateemail($aPostData['Email'])===false)
    {
    $aErrors['Email']='Please enter a valid Email address';}
    //if(validateemail(!$aPostData['Email'])===false)
    //{
    // $aErrors['Email']='Please enter your Email';
    //}
    if(!$aPostData['Address'])
    {
    $aErrors['Enquiry']='Please enter your Address';
    }
    if(!$aPostData['Business_Name'])
    {
    $aErrors['Business_Name']='Please enter your Business Name';
    }
    if(!$aPostData['Type_of_Business'])
    {
    $aErrors['Type_of_Business']='Please enter your Type of Business';
    }


    if (count($aErrors) > 0) return array(false, $aErrors);

    return array(true);
    }


    }
    ?>[/code]

    Line 35 which is below is whats causing the problem:

    if(validatename($aPostData['Name'])===false)
  18. Hi

    Im trying to validate the name field so that no numbers can be inputted. Here is my function in my Clients table class:

    [code]private function ValidateClientData($aPostData)
    {
    $aErrors = array();

    if(validatename($aPostData['Name'])===false)
    {
    $aErrors['Name']='Please enter your Name';}

    if(validateemail($aPostData['Email'])===false)
    {
    $aErrors['Email']='Please enter a valid Email address';}
    //if(validateemail(!$aPostData['Email'])===false)
    //{
    // $aErrors['Email']='Please enter your Email';
    //}
    if(!$aPostData['Address'])
    {
    $aErrors['Enquiry']='Please enter your Address';
    }
    if(!$aPostData['Business_Name'])
    {
    $aErrors['Business_Name']='Please enter your Business Name';
    }
    if(!$aPostData['Type_of_Business'])
    {
    $aErrors['Type_of_Business']='Please enter your Type of Business';
    }


    if (count($aErrors) > 0) return array(false, $aErrors);

    return array(true);
    }


    }
    ?>[/code]

    I then have a globals file which contains the 'validatename' function:

    [code]function validate_email ($email)
    {
    if(ereg('^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*$', $email))
    {
    return true;
    }
      else
    {
        return false;
    }
    }

    function validateemail ($email)
    {
    return validate_email($email);

    function validate_name ($name)
    {
    if(ereg("/^[a-zA-Z\-\Ä\ä\Ö\ö\Ü\ü\s]+$/s", $name))
    {
    return true;
    }
      else
    {
        return false;
    }

    }
    function validatename ($name)
    {
    return validate_name($name);
    }[/code]

    As you can see its exactly the same as the email function except the characters that are accepted.

    I get the error
    Fatal error: Call to undefined function validatename() in /mnt/k/*****/website/_lclasses/Tables/RCLTblClients.class.php on line 35

    Anyone know why?

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