PHP - N00b Help...no Doubt
Hi All,
being a noob when it comes to any sort of coding I am facing a strong learning curve but I'm getting there. With the implementation of our new client portal, we require a new client sign-up api...The following was provided... <?php ////////////////////////////////////////////////////// // THIS CODE IS PROVIDED AS AN EXAMPLE OF HOW TO // USE THE DITTO PORTAL FOR AHSAY API'S. ////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // SET API VARIABLES ///////////////////////////////////////////////////////////////// //SET CUSTOMER ID AND API KEY $customerID = '8000003'; $key = '6NbTmZw5LZdtTO8FuYH9G'; //IF POSTBACK if ($_SERVER['REQUEST_METHOD'] == 'POST') { ///////////////////////////////////////////////////////////////// // GET VALUES FROM FORM ///////////////////////////////////////////////////////////////// $company = $_REQUEST['company']; $address1 = $_REQUEST['address1']; $address2 = $_REQUEST['address2']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $postal = $_REQUEST['postal']; $country = $_REQUEST['country']; $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $type = $_REQUEST['type']; $username = $_REQUEST['username']; $alias = $_REQUEST['alias']; $language = $_REQUEST['language']; $timezone = $_REQUEST['timezone']; ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { if ($country == $c->countryID) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\" selected>".$c->countryName.""; } else { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { if ($language == $l->languageID) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\" selected>".$l->languageName.""; } else { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { if ($timezone == $t->timezoneID) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\" selected>".$t->timezoneName.""; } else { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ///////////////////////////////////////////////////////////////// // BEFORE CALLING THE ADDCLIENT API, YOU SHOULD VALIDATE THE // USER'S INPUT (ALL REQUIRED FIELDS COMPLETE, EMAIL ADDRESS // ETC. ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // INVOKE ADD CLIENT API TO ACTIVATE ACCOUNT ///////////////////////////////////////////////////////////////// //SET ACCOUNT TYPE AND TRIAL LENGTH $account = 'TRIAL'; $length = '14'; //BUILD URL FOR API CALL $function = 'AddClient'; $url = 'https://api.web-portal.co/?'. "customerID=".$customerID. "&key=".$key. "&function=".$function. "&company=".$company. "&address1=".$address1. "&address2=".$address2. "&city=".$city. "&state=".$state. "&postal=".$postal. "&country=".$country. "&firstname=".$firstname. "&lastname=".$lastname. "&phone=".$phone. "&email=".$email. "&type=".$type. "&username=".$username. "&alias=".$alias. "&language=".$language. "&timezone=".$timezone. "&account=".$account. "&length=".$length; //MAKE API CALL USING SIMPLE XML $createClient = simplexml_load_file($url); //DISPLAY RESULTS OF API CALL echo $createClient; } //NOT POSTBACK else { ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <p>NEW CLIENT SIGN UP</p> <form id="NewClientForm" name="NewClientForm" method="post" action="NewClientForm.php"> <p>Company Name:<br /> <label for="company"></label> <input type="text" name="company" id="company" value="<? echo $company; ?>" /> </p> <p>Address 1:<br /> <label for="address1"></label> <input type="text" name="address1" id="address1" value="<? echo $address1; ?>" /> </p> <p>Address 2:<br /> <label for="address2"></label> <input type="text" name="address2" id="address2" value="<? echo $address2; ?>" /> </p> <p>City:<br /> <label for="city"></label> <input type="text" name="city" id="city" value="<? echo $city; ?>" /> </p> <p>State/Province:<br /> <label for="state"></label> <input type="text" name="state" id="state" value="<? echo $state; ?>" /> </p> <p>Zip/Postal Code:<br /> <label for="postal"></label> <input type="text" name="postal" id="postal" value="<? echo $postal; ?>" /> </p> <p>Country:<br /> <label for="country"></label> <select name="country" id="country"> <? echo $countryOptions; ?> </select> </p> <p>Primary Contact First Name:<br /> <label for="firstname"></label> <input type="text" name="firstname" id="firstname" value="<? echo $firstname; ?>" /> </p> <p>Primary Contact Last Name:<br /> <label for="lastname"></label> <input type="text" name="lastname" id="lastname" value="<? echo $lastname; ?>" /> </p> <p>Primary Contact Telephone:<br /> <label for="phone"></label> <input type="text" name="phone" id="phone" value="<? echo $phone; ?>" /> </p> <p>Primary Contact Email:<br /> <label for="email"></label> <input type="text" name="email" id="email" value="<? echo $email; ?>" /> </p> <p>Account Type:<br /> <input type="radio" name="type" id="acb" value="ACB" /> <label for="acb">ACB</label> <input type="radio" name="type" id="obm" value="OBM" /> <label for="obm">OBM</label> </p> <p>Preferred Username:<br /> <label for="username"></label> <input type="text" name="username" id="username" value="<? echo $username; ?>" /> </p> <p>Alias/Nickname:<br /> <label for="alias"></label> <input type="text" name="alias" id="alias" value="<? echo $alias; ?>" /> </p> <p>Language:<br /> <label for="language"></label> <select name="language" id="language"> <? echo $languageOptions; ?> </select> </p> <p>Timezone:<br /> <label for="timezone"></label> <select name="timezone" id="timezone"> <? echo $timezoneOptions; ?> </select> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Sign Up" /> </p> </form> <p><br /> </p> </body> </html> The following errors are produced... http://cubetech.com.au/downloads/signup.php Can please confirm my suspicions of simplexml_load_file() are not permitted. I have been reading about cURL implementation instead can someone provide some assistance if this is possible and assist. A lot of thank in advance, Andrew Chapman Similar Tutorialswhats the diff between echo,print,print_r what's the difference between include(),require,require_once Friends, suppose iam copying 1 to 100 files using a loop in php & when the copy process reach at 50th file my browser went offline. My doubt is will it copy all 100 files ?? OR it will terminate at 50th file ? if i want to get all files copied if the browser went offline then what i want to do ?? Please clear I am trying to run tests on my pages and see how much time each one of em take to execute. For this purpose, i'm using this code which i got online: Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> microtime() returns microseconds & secs since Unix epoch. So after exploding, why do we add them both? Cant we just use the microseconds part? I've tried this code & the one above & both return same time(almost). Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> Hi all, Can anyone offer assistance with the following: I am trying to obtain a score from a users radio button selection on a simple quiz. i am not able to obtain the results.... I'm not sure if this is exactly a coding help question, excuse me if its not. I want to know what is the best & secure way to submit a form to itself. I've tried to google the answer, but did not get a proper answer with explanation or may be I didnt use proper keywords to search it. Out of these which one do i use? Code: [Select] // Leave the action field empty. <form method="POST" action=""> //$PHP_SELF, also if i use echo $PHP_SELF my form does not work like it should. <form method="POST" action="<?$PHP_SELF?>"> //$_SERVER['PHP_SELF'], same problem as $PHP_SELF, it doesnt work if i use echo. <form method="POST" action="<?$_SERVER['PHP_SELF']?>"> Hello guys, i need to create a code for making connections with SSL servers (particularly SMTPS and POP3S) and i know about the existence of OpenSSL extension. However, i'm in doubt about a basic issue: 1. Is this extension useful for creating SSL clients or SSL servers? I'm not a SSL expert, so maybe i'm misunderstanding something; i hope you can help me. Kind regards. I have been getting into PHP recently and have started a little 'social network' project to learn from and test my development. So far I've gotten my head around the MYSQL and login/registration scripts as well as denoting certain pages for logged in members as opposed to the home page (for example) that everyone can see. The problem I now have is with the accounts, I know what I want but I haven't a clue on how to code what it is I am wanting, nor the knowledge of where to start. It's the basic things such as; Inboxes and messaging system, forums, friends guestbooks, blogs, videos pictures etc.. Hey there (: I'm doing a resume site for the FBLA club at my highschool. I'm also learning PHP along the way. I'm sure this is pretty obvious, but i'm getting this error, and I cant figure out what it means: Code: [Select] Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home2/bythewa1/public_html/resume/profile.php:5) in /home2/bythewa1/public_html/resume/profile.php on line 7 Here is my page code: Code: [Select] <? include($root_path.'includes/header.php'); ?> <? if(!isset($_SESSION['login'])) { session_register('login, userid, firstname, lastname'); } if($_GET['logout'] == 'yes') { session_unregister('login'); session_unregister('userid'); session_unregister('firstname'); session_unregister('lastname'); } //die("In"); if(!$_SESSION['login'] == 0) { // die("Here"); ?> <script language="javascript"> window.location = 'http://resume.derekbtw.com/index.php'; </script> <? } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <h1><a href="<?=$_SERVER['PHP_SELF']?>?logout=yes">logout</a></h1> </body> </html> I have a php code that call a process (a java program). The process runs in background for a so long time - from 1 minute to 2 hours. I make the process call using exec:
<?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " &> /dev/null &"); } } $command = "java ... ReadEmailsCmdLine 2>&1"; execInBackground($command); echo "FINALIZADO";Though the command runs in background it looks that the PHP code wait for the command completion to send a answer to client browser because I just see "FINALIZADO" after the java program finished its execution. Does someone know how I can solve this problem? Or at least does have a hint/pointer for that? Since now I thanks any comment/suggestion With the following code I am getting the Fatal Error: Maximum Execution time of 30 seconds exceeded. $weather_data = simplexml_load_file('ftp://ftp2.bom.gov.au/anon/gen/fwo/IDV10450.xml'); $issuedate_pre = $weather_data->xpath('amoc/issue-time-utc'); echo $issuedate_pre."\n"; $issuedate_post = DateTime::createFromFormat('Y-m-d?H:i:s?', $issuedate_pre); echo $issuedate_post."\n"; $issuedate_unix = $issuedate_post->format('U'); echo $issuedate_unix; The page reads that "Line 10" is to blame for this, that is the first line in that script. I would have thought it might happen if the server doesn't respond, but if you go to the source of the XML it will load in a few seconds. Any help on how to load the XML properly would be greatly appreciated. Regards. Hi Guys, Real PHP newbie here, and slowly getting to grips with it (I did say slowly, right!). Basically, I've created this register page. It's supposed to ask the user for their username, password, password verificiation, email address and then finally to ask the user to select from a tick list of interests (populated via the DB). Here's my code: <? include('includes/config.php'); $is_error = 0; if ($_POST['task'] == 'singup_do') { $signup_username = $_POST['user_username']; $signup_password = $_POST['user_password']; $signup_pwd_again = $_POST['user_password_again']; $signup_email = $_POST['user_email_address']; $signup_interest = $_POST['signup_interest']; if ($signup_username == ''){ $is_error = 1; $signup_username_msg = 'The username cannot be left blank'; } if ($signup_password == ''){ $is_error = 1; $signup_password_msg = 'Password field cannot be left blank'; } if ($signup_pwd_again == ''){ $is_error = 1; $signup_pwd_again_msg = 'Password again field cannot be left blank'; } if ($signup_email == ''){ $is_error = 1; $signup_email_msg = 'Email cannot be left blank'; } if ($signup_email != '' && !validateEmailAddress($signup_email)) { $is_error = 1; $signup_email_msg = 'Incorrect E-mail address'; } if (!is_array($signup_interest) || count($signup_interest)==0){ $is_error = 1; $signup_interest_msg = 'Please select atleast one interest'; } //EMAIL ADDRESS VALIDATION if ($signup_password!='' && $signup_pwd_again!='' && $signup_password != $signup_pwd_again) { $is_error = 1; $error_msg = 'Passwords don\'t match'; } //USERNAME DUPLICATION VALIDATION if (!$is_error && $signup_username!='' && !checkUsername($signup_username)) { $is_error = 1; $signup_username_msg = 'Username already taken, please enter another'; } if (!$is_error) { $signup_interest_ids = ( is_array($signup_interest) ? implode(',', $signup_interest) : '' ); $users_insert = "INSERT INTO users SET user_id='', user_username = '{$signup_username}' , user_password='{$signup_password}', user_email_address = '{$signup_email}', users_interests='{$signup_interest_ids}', user_active='Y', user_date_added=NOW()"; mysql_query($users_insert); header('Location:login.php?signup=success'); } } ?> <html> <head> <title>Register</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body > <div align="center"><BR><BR><BR> <div style="width:50%; "> <form name="frmSignup" action="sign_up.php" method="post"> <input type="hidden" name="task" value="singup_do"> <table width="100%" border="0" cellspacing="4" cellpadding="4" align="center"> <? if ($error_msg!='') {?> <tr><td> </td><td class="tahoma10rednormal"><?=$error_msg?></td></tr> <? }?> <tr><td width="20%" valign="top">Username : </td><td><input name="user_username" type="text" class="textfield" size="35" value="<?=$signup_username?>"/><? if ($signup_username_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_username_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password : </td><td><input name="user_password" type="password" class="textfield" size="35" value="<?=$signup_password?>"/><? if ($signup_password_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_password_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password (again): </td><td><input name="user_password_again" type="password" class="textfield" size="35" value="<?=$signup_pwd_again?>"/><? if ($signup_pwd_again_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_pwd_again_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Email address: </td><td><input name="user_email_address" type="text" class="textfield" size="35" value="<?=$signup_email?>"/><? if ($signup_email_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_email_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2" ><b>Interests:</b><? if ($signup_interest_msg!='') { echo ' <span class="tahoma10rednormal">' . $signup_interest_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2"> <? $categories = getCategories(); $categories_count = count($categories); if (is_array($categories)) { $cat_counter=0; ?> <table width="80%" border="0" cellspacing="4" cellpadding="4"> <? foreach($categories as $cats) { if ($cat_counter==0 || ($cat_counter%4) == 0) echo '<tr>'; $chk_selected = ''; if (is_array($signup_interest) && in_array($cats['id'], $signup_interest)) $chk_selected = "CHECKED"; ?> <td><input type="checkbox" name="signup_interest[]" value="<?=$cats['id']?>" <?=$chk_selected?>><?=$cats['text']?></td> <? if ($cat_counter==$categories_count || ($cat_counter%4) == 3) echo '</tr>'; $cat_counter++; } ?> </table> <? } else { echo 'No interest added yet.'; } ?> </tr> <tr> <td> </td> <td><input type="submit" name="submit_btn" value="Sign Up"> <input type="button" name="cancel_btn" value="Cancel" onClick="window.location.href='index.php'"></td> </tr> </table> </div> </div> </body> </html> I'm getting undefined varible errors for: Notice: Undefined variable: error_msg Undefined variable: signup_username_msg Notice: Undefined variable: signup_password_msg Notice: Undefined variable: signup_pwd_again_msg Notice: Undefined variable: signup_email_msg Notice: Undefined variable: signup_interest_msg Notice: Undefined variable: signup_interest Notice: Undefined variable: signup_interest Which as the canny of you will have noticed, is all of them! Hurrah at least I'm consistent! If anyone could help out a n00b I'd be so so grateful. Thanks! Rob so, I've been trying to build a contact form for about a week now. straight. no kidding. I'm entirely new to php and basically know nothing more than i can assume based on other scripting/coding experience. I know there's probably answers to similar questions all over the place, but I've been trying literally hundreds of different pre-built forms guaranteed to work and solutions to others' problems, etc etc and not a single one has operated correctly for me. I can't really do anything with a "you should try this/that approach" answer, nor can I be assumed to know anything about php; I pretty much just need someone to fix whatever the problem is and paste it back to me as this is the only thing keeping me from launching the site. this is what prints when trying to submit with the dropdown on the default value: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. this prints when any item other than the default is selected in the dropdown: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5810110\html\contact\contact.php on line 33 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. http://email.about.com/cs/standards/a/smtp_error_code_2.htm specifically states to ignore both these errors, yet http://cr.yp.to/docs/smtplf.html specifically states that it's a fault of mine. here's the html: Code: [Select] <div id="formHolder"> <form method="post" action="contact.php"> <table class="contactTable" align="center"> <tr> <td> Subject: </td> <td> <select name="sendto"> <option value="bs from N1K.com">General Inquiry</option> <option value="JOB OFFER">Design Contract</option> <option value="PURCHASE ORDER">Purchase Order/Offer</option> </select> </td> </tr> <tr> <td><font color=red>*</font>Name:</td> <td><input size=25 name="Name"></td> </tr> <tr> <td><font color=red>*</font>Email:</td> <td><input size=25 name="Email"></td> </tr> <tr> <td>Company:</td> <td><input size=25 name="Company"></td> </tr> <tr> <td>Phone:</td> <td><input size=25 name="Phone"></td> </tr> <tr> <td>Subscribe to<br> mailing list: </td> <td><input type="radio" name="list" value="No"> Pf, nothx.<br> <input type="radio" name="list" value="Yes" checked> H3X Y34!<br> </td> </tr> <tr> <td colspan=2>Message:</td> </tr> <tr> <td colspan=2 align=center> <textarea name="Message" rows=5 cols=35></textarea> </td> </tr> <tr> <td colspan=2 align=center> <input type=submit name="send" value="Submit"> </td> </tr> </table> </form> </div><!-- END formHolder --> and here's the php: <?php $to = "god@neurot1k.com" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = $_REQUEST['sendto'] ; $fields = array(); $fields{"Name"} = "Name"; $fields{"Company"} = "Company"; $fields{"Email"} = "Email"; $fields{"Phone"} = "Phone"; $fields{"list"} = "Mailing List"; $fields{"Message"} = "Message"; $body = "I have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: god@neurot1k.com"; $subject2 = "autoconfirm from neurot1k.com"; $autoreply = "Thanks for the contact, I'll get back to you as soon as possible, usually within 48 hours. If you have any more questions, please try me on AIM: ycleptCrux"; if($from == '') { print "You have not entered an email, please go back and try again"; } else { if($name == '') { print "You have not entered a name, please go back and try again"; } else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) { print "Thanks, I'll get back to you as soon as possible."; } else { print "There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]."; } } } ?> the form was copy/pasted from http://php.about.com/od/phpapplications/ss/form_mail.htm and then respective variables were changed (email address, dropdown fields, etc). I didn't think it'd be SUCH a problem to copy/paste a pre-written block of code from About.com... HUGE thanks in advance to anyone willing to helo. I apologize in advance, I know pretty much nothing about PHP - don't hate me, please! But I'm working on a form mailer, and it functions, but what I don't like is it leaves all the text fields, blank or not, in my email, which makes it difficult for my client to read, so theres a long list of txt field1: another text field: blah blah: all the way down the email - and I want it gone! haha. I've researched how to do this, but basically, I have no idea how to implement it into my code and don't have time right now to up and learn PHP. My code is as follows: Code: [Select] <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'PCI Tour/Excursion Request'; // Your email address. This is where the form information will be sent. $emailadd = 'MY EMAIL HERE'; // Where to redirect after form is processed. $url = 'FORWARDING URL'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> IT was a very simple copy-paste form, but I have no idea what on earth I'm doing. If anyone has any ideas I would GREATLY appriciate the help! Thanks! -Austin |