Jump to content

Kyrus

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kyrus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone. I'd like to know how to duplicate a product through a php back-office. That product consists of an ID in the "products" table of my DB. Then we have another table called "sub_products" that links its sub-products through a column named "product_id". So I have product with ID "1000", and sub-products associated with it on another table with ID's "2021", "2022", "2023". What's the routine I can use to duplicate both the product and its sub-products? I need to duplicate them because they fit 2 categories so I'm changing the category column during this duplicate. Could really use some help. Thank you in advance!
  2. Hi everyone. I'd like some help here if you can. I'll explain: I've built a form in html (which you can see here: http://www.bastosviegas.com/bastos_pt/encomendar_serv.php) with a javascript to enable people to add row on a table. Here's the javascript: <script type="text/javascript"> function addRowToTable() { var tbl = document.getElementById('tblAddress'); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow; // var iteration = lastRow + 1; var row = tbl.insertRow(lastRow); // cell 0 var cell0 = row.insertCell(0); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'cod[]'; el.id = 'cod[]'; el.size = 14; cell0.appendChild(el); //cell 1 var cell1 = row.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'descri[]'; el.id = 'descri[]'; el.size = 48; cell1.appendChild(el); //cell 2 var cell2 = row.insertCell(2); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'qty[]'; el.id = 'qty[]'; el.size = 14; cell2.appendChild(el); } </script> The rest of the html is pretty straight forward. The ID's given to the 3 cells I'm having trouble with are cod[] , descri[] , qty[]. This brings us to my problem, which i believe is in the php file which is being used by the form. The purpose of this is to email the form. I can get it to work with simple input field IDs (unique), but it's not passing the array of values for my cod[] , descri[] , qty[]. I suppose this is a code flaw on my part (I'm not a programmer, although I like to develop this kind of stuff), so here's the code: (i've taken out some parts that don't matter for this case) <?php $to = "email@address.com"; $fax = $_POST['fax']; $email = $_POST['email']; $arrCod = explode("\n", $_POST["cod"]); $arrDescri = explode("\n", $_POST["descri"]); $arrQty = explode("\n", $_POST["qty"]); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Site encomenda"; $EmailBody = " Fax: $fax\n Email: $email\n "; foreach ( $arrCod as $codigos ) { $EmailBody .= " Codigo: $codigos\n"; } foreach ( $arrDescri as $descricao ) { $EmailBody .= " Descricao: $descricao\n"; } foreach ( $arrQty as $quantidade ) { $EmailBody .= " Quantidade: $quantidade\n"; } // Validation stuff // mail() function exit; ?> After all this, the email I get is this: Codigo: Array Descricao: Array Quantidade: Array How can I get this to work? Thank you very much!
  3. Hello. Very quick version: Does anyone know how to encode an attachment in MIME to accept line rbeaks in.txt documents? Long version: I have this code that puts the attachment into my email that I'm gonna send below on the code. $fileatt = "encomendas/$filename.txt"; // Path to the file $fileatt_type = "text/html"; // File Type $fileatt_name = "$filename.txt"; // Filename that will be used for the file as the attachment $email_from = "geral@bastosviegas.com"; // Who the email is from $email_subject = "Encomenda"; // The Subject of the email $email_txt = "Dados do Cliente referente a Medicalexpress online<br>\n<br>\nNúmero: $nr <br>\n Nome: $name <br>\n Endereço: $endereco <br>\n Localidade: $localidade <br>\n Código postal: $cod_postal <br>\n País: $pais <br>\n Telefone: $telefone <br>\n Fax: $fax <br>\n Profissão: $profissao <br>\n Actividade: $actividade <br>\n Met. pagamento: $metpag <br>\n Email: $email <br>\n Nr. Contribuinte: $nrcont <br>\n Mensagem: $msg"; $email_to = "pedropeixoto@bastosviegas.com"; // Who the email is too $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $enc_txt = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n" . $email_txt . "\n\n"; $enc_txt = chunk_split(base64_encode($enc_txt)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $enc_txt . "\n\n" . "--{$mime_boundary}--\n"; It works. It sends the .txt attachment I want in the email. The thing is, the .txt that comes with the email isint accepting line breaks. I guess it has to do with the base64 encoding so please can anyone tell me how to encode my .txt to accept line breaks? Thank you.
  4. Hi everyone. I'm currently working on a Product Configurator for a company, and could use your help here. I've never built something like this so I'd like to know if there is anything like this written already so I have a base from where I can work. The architecture would be something like the attachment. So, any of you know something similar? Any pro tips you can give me? Thank you. [attachment deleted by admin]
  5. Ok I got something working now. The following code displays the last name checked (not all yet, but least something is working): $to = "pedropeixoto@live.com"; // $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $meet = $_POST['meet']; foreach ($meet as $m) $hour = $_POST['hour']; $quote = $_POST['quote']; $day = $_POST['day']; $sub = "On-line Medica 2008 meeting booking."; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Meeting information:"; $EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\nMeeting with: $m. \nOn the $day at $hour\nAdditional details: $quote\n"; mail($to, $sub, $EmailBody, $headers); echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> "; } The problem might be the way i output it in $emailBody variable. $EmailBody = "Meeting with: $m. \n"; Is this correct?
  6. Hi again. I did what you said and here's the code now: <?php $to = "pedropeixoto@live.com"; // $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $meet = $_POST['meet']; foreach ($meet as $value) { strip_tags($value)"; echo "$value<br>"; } $hour = $_POST['hour']; $quote = $_POST['quote']; $day = $_POST['day']; $sub = "On-line Medica 2008 meeting booking."; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Meeting information:"; $EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\nMeeting with: &meet\n On the $day at $hour\nAdditional details: $quote\n"; //if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z­]{2,3})$", //$email)) { // echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>O Email que foi inserido não tem um formato valido, por favor insira um email valido</h3></font></div>"; //echo " <meta http-equiv=\"refresh\" content=\"3;URL=catalogo.php\"> "; //exit; //} if(empty($name)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the NAME which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } if(empty($company)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the COMPANY which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } if(empty($email)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the E-MAIL which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } if(empty($meet)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't check in the PERSON WITH WHOM YOU WANT TO MEET, which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } if(empty($hour)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the TIME which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } if(empty($day)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the DAY which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } else { mail($to, $sub, $EmailBody, $headers); echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> "; } Problem is, it's giving me a programming error. I'm not sure where to put the "foreach" and I'm positive it shouldn't be like this. Apolagize my ignorance but could you please elaborate?
  7. Users would be able to select more than one eprson to meet. Here's the link: www.bastosviegas.com/form.php Scroll through the array. That's what I can't figure out. Could you give me an example? If possible applicable to this code. Thank you.
  8. Hello people. I'm working on this form where people can book their meetings online. I've got a few checkboxes there so people can choose with whom they want to meet. Thing is, the email I get here displays "Array" rather than displaying the persons that they checked. Suggestions? Here is the code for the checkboxes: <br /> <input name="meet[]" type="checkbox" id="meet[]" value="Luis Guimarães" /> Luis Guimarães <br /> <br /> <input name="meet[]" type="checkbox" id="meet[]" value="Carlos Gonçalves" /> Carlos Gonçalves <br /> <input name="meet[]" type="checkbox" id="meet[]" value="Francisco Pestana" /> Francisco Pestana<br /> <input name="meet[]2" type="checkbox" id="meet[]2" value="Carla João Ribeiro" /> Carla João Ribeiro<br /> <input name="meet[]3" type="checkbox" id="meet[]3" value="Vitália Barros" /> Vitália Barros<br /> <input name="meet[]4" type="checkbox" id="meet[]4" value="Isabel Calisto" /> Isabel Calisto</p> <p align="left" class="style23"> <input name="meet[]5" type="checkbox" id="meet[]5" value="Luís Vasconcelos" /> Luís Vasconcelos<br /> <input name="meet[]6" type="checkbox" id="meet[]6" value="Raquel Ribeiro" /> Raquel Ribeiro</p> <p align="left" class="style23"> <input name="meet[]7" type="checkbox" id="meet[]7" value="Miguel Guimarães" /> Miguel Guimarães</p> <p align="left" class="style23"> <input name="meet[]8" type="checkbox" id="meet[]8" value="Vasco Guimarães" /> Vasco Guimarães<br /> <input name="meet[]9" type="checkbox" id="meet[]9" value="Rita Ferreira" /> Rita Ferreira<br /> <input name="meet[]10" type="checkbox" id="meet[]10" value="Teresa Santos" /> Teresa Santos</p> <p align="left" class="style23"> <input name="meet[]11" type="checkbox" id="meet[]11" value="Jaime Membrive" /> Jaime Membrive<br /> <input name="meet[]12" type="checkbox" id="meet[]12" value="Cristina Torruella " /> Cristina Torruella An here is the send_from.php: <?php $to = "pedropeixoto@live.com"; // $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $meet = $_POST['meet']; $hour = $_POST['hour']; $quote = $_POST['quote']; $day = $_POST['day']; $sub = "On-line Medica 2008 meeting booking."; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Meeting information:"; $EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\n[b]Meeting with: &meet[/b]\n On the $day at $hour\nAdditional details: $quote\n"; //if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z­]{2,3})$", //$email)) { // echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>O Email que foi inserido não tem um formato valido, por favor insira um email valido</h3></font></div>"; //echo " <meta http-equiv=\"refresh\" content=\"3;URL=catalogo.php\"> "; //exit; //} if(empty($company)) { echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the COMPANY which is required to book a meeting with us.</h3></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> "; exit; } else { mail($to, $sub, $EmailBody, $headers); echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>"; echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> "; } ?> An this is the e-mail i get: Meeting information: Name: Pedro Peixoto Company: Company of Heroes E-mail: blabla@live.com Wants to meet with: Array On the November 20th at 10:00 Additional details: Additional notes? Please write here. Thank you in advance.
  9. $var1 = ''; $var2 = ''; $var3 = 'foo'; $var4 = 'bar'; What am I supposed to write after the = ? I wrote: $var1 = ''; $var2 = 'descricao'; $var3 = 'mod'; $var4 = 'tam'; But once I put it online I get "descricao" on the field I want to print.
  10. Hello Ben. <?php $sql = "SELECT id,description,model,size FROM yourtable"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo 'Product ID: '.$row['id']; echo '<br />'; if(!empty($row['description'])){ echo $row['description']; }else{ echo 'Model: '.$row['model'].' Size: '.$row['size']; } echo '<br /><br />'."\n"; } ?> This is a bit too much for me. I applied it but it gives me all the models and Sizes of ALL products. The page just extends forever considering the amount of products I have in the DB. I need a simple solution. My code at the moment is as simple as this: <? echo $descri; ?> I've already set $descri to the description field in the database, and set $mod and $tam for model and size too. All I need now is a code that says something like this: If $descri field is empty then check $mod, if $mod is empty too then check $tam, if $tam empty then check $blablabla. If every field is empty then don't print anything. This code is already on a table in the exact position to be printed, no need to farmat the text, just print the data it finds on the DB. Thanks for your time.
  11. Hello. I'm rather new to php, been reading here and there, editing some pre-made codes etc. Just so you know my bases. Let's go direct to the point then. I need to echo the descriptions of the products in the cart page of my website, so far so good, but there are some products that don't have descriptions, instead they have models, sizes, etc. What I need to do is to build a code that checks if the product has description, if so print it, if not, then print the model, if theres no model then print the size. Something like this. Anyone knows how to do this? Thanks in advance.
×
×
  • 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.