Converting PHP to JSP
For work I need to convert a code that I wrote in PHP to JSP in order for it to run on our windows server.
Trouble is, I know very little java. The script is a very simple, short email script located here: http://pastebin.com/m7b4b4e96
Any help would be greatly appreciated.
Perhaps this one?
http://www.amazon.com/Murachs-Java-Servlets-Andrea-Ste
elman/dp/1890774189/ref=pd_sim_b_5_img/002-0859111-900
5647I have read many many JSP and Servlet books in the past and the book you mentioned (Murachs-Java-Servlets book by Andrea Steelman) is the best by far above any other books.
Similar Messages
-
String manipulation: php to jsp
Im converting a menu generation program from PHP to JSP.
Every page in my site has been allocated a page Id.
A pages pageId determines how the primary navigation of the page displays.
My Question
I need to determine the sub Menu parent id To do this in php I can just take the int value of the pageId string to get 2
<?php
$pageId = "2.1.3.4";
$subMenuParentId = intval($pageId);
?>
how can I do this in JSP ? Is there a better solution.
<%
String pageId = "2.1.3.4";
%>You might find this test program novel...
import java.text.*;
public class msgfmttest
public static void main(String[] args)
MessageFormat msgfmt = new MessageFormat("{0,number,integer}.{1,number,integer}.{2,number,integer}.{3,number,integer}");
String pageId = "2.1.3.4";
try {
Object[] levels = msgfmt.parse( pageId );
int level1 = ( (Long)levels[0] ).intValue();
int level2 = ( (Long)levels[1] ).intValue();
int level3 = ( (Long)levels[2] ).intValue();
int level4 = ( (Long)levels[3] ).intValue();
System.out.println("level 1: " + level1);
System.out.println("level 2: " + level2);
System.out.println("level 3: " + level3);
System.out.println("level 4: " + level4);
catch(ParseException exc) {
System.err.println("pageId is invalid");
} -
Convert php script to oracle procedure
To all please help me... I wanna convert php script to oracle procedure..and the script is (exp)..
<?php
include("../config/koneksi.php");
$customer=$_POST['customer'];
$tanggal1=$_POST['theDate1'];
$tanggal2=$_POST['theDate2'];
$no_bulan=substr($tanggal1,0,2);
$bulan_sajah= (substr($no_bulan,0,1)=='0')? substr($no_bulan,1,1) : $no_bulan;
$tahun_sajah=substr($tanggal1,3,4);
$blnkmrn=(int)$bulan_sajah;
$thnkmrn=(int)$tahun_sajah;
if ($blnkmrn==1) {
$bulan_lalu=12;
$tahun_lalu=$thnkmrn-1;}
else {
$bulan_lalu=$blnkmrn-1;
$tahun_lalu=$thnkmrn;
$bulanlalu=strval($bulan_lalu);
$tahunlalu=strval($tahun_lalu);
$sql = "select nip_nas from edo_customer_master_dives where standard_name='$customer'";
$stm = ociparse($conn,$sql);
ociexecute($stm);
ocifetch($stm);
$data=ociresult($stm,1);
$sql12 = "select PRODUCT_LINE_ID,sum(REVENUE)
from PA_FACT_REV_BILLED_CC
where nip_nas='$data' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
$stm12 = ociparse($conn,$sql12);
ociexecute($stm12);
$total_revenue=0;
$i="0";
while (ocifetch($stm12)){
$rev_items=ociresult($stm12,1);
$revenue=ociresult($stm12,2);
$sql2 = "select * from PA_FACT_REV_BILLED_CC
where nip_nas='$data' and PRODUCT_LINE_ID='$rev_items'";
$stm2 = ociparse($conn,$sql2);
ociexecute($stm2);
ocifetch($stm2);
$tahun=ociresult($stm2,1);
$bulan=ociresult($stm2,2);
$nipnas=ociresult($stm2,3);
$prod_line=ociresult($stm2,4);
$rev_item=ociresult($stm2,5);
//$revenue=ociresult($stm2,6);
$query1 = "select standard_name from edo_customer_master_dives where nip_nas='$nipnas'";
$st1 = ociparse($conn,$query1);
ociexecute($st1);
ocifetch($st1);
$nama_cust=ociresult($st1,1);
$query2 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$prod_line'";
$st2 = ociparse($conn,$query2);
ociexecute($st2);
ocifetch($st2);
$nama_prod_line=ociresult($st2,1);
$query3 = "select REV_TYPE_LNAME from parameter.p_rev_type@dwhnas where REV_TYPE_ID='$rev_item'";
$st3 = ociparse($conn,$query3);
ociexecute($st3);
ocifetch($st3);
$nama_rev_item=ociresult($st3,1);
$query4="select sum(total_usage) from PA_FACT_TRAFFIC_CC where PRODUCT_LINE_ID='$prod_line' and nip_nas='$nipnas' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
$st4 = ociparse($conn,$query4);
ociexecute($st4);
ocifetch($st4);
$total_usage=ociresult($st4,1);
$total=$revenue + $total_usage;
echo $tahun." ".$bulan." ".$nama_cust." ".$nama_prod_line." ".$nama_rev_item." ".$revenue." ".$total_usage." ".$total."<br>";
$total_revenue=$total_revenue+$total;
$i++;
echo $total_revenue;
//cost of product
$query5="select * from PA_FACT_TRAFFIC_CC where nip_nas='$nipnas' and year_id='$tahunlalu' and month_id='$bulanlalu'";
$st5 = ociparse($conn,$query5);
ociexecute($st5);
$total1=0;
$total2=0;
$total3=0;
$total4=0;
$total5=0;
while (ocifetch($st5)){
$nipnas=ociresult($st5,3);
$lineid=ociresult($st5,4);
$itemid=ociresult($st5,5);
$call=ociresult($st5,6);
$unit=ociresult($st5,7);
$query6 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$lineid'";
$st6 = ociparse($conn,$query6);
ociexecute($st6);
ocifetch($st6);
$nama_prod_line=ociresult($st6,1);
$query7 = "select REV_item_LNAME from parameter.p_rev_item@dwhnas where REV_item_ID='$itemid'";
$st7 = ociparse($conn,$query7);
ociexecute($st7);
ocifetch($st7);
$nama_rev_item=ociresult($st7,1);
$query8 = "select * from cost_of_product where prod_line_lname='$nama_prod_line' and REV_item_LNAME='$nama_rev_item' and end_date is null";
$st8 = ociparse($conn,$query8);
ociexecute($st8);
ocifetch($st8);
$lineid_cost=ociresult($st8,1);
$itemid_cost=ociresult($st8,2);
$satuan=ociresult($st8,5);
$nilai=ociresult($st8,7);
if (strtoupper($satuan)=='MENIT') $total1=$total1+(($unit/60)*$nilai);
if (strtoupper($satuan)=='KBPS') $total2=$total2+($unit*$nilai);
if (strtoupper($satuan)=='SMS') $total3=$total3+($call*$nilai);
if (strtoupper($satuan)=='SSL') $total4=$total4+($call*$nilai);
if (strtoupper($satuan)=='SST') $total5=$total5+($call*$nilai);
$total_cost_pots=$total1+$total2+$total3+$total4+$total5;
echo $total_cost_pots;
?>
this script just for exp.Please convert step by step. for example
(1) remove inverted quotation mark ( ` )
(2) modify constraints syntax (PRIMARY KEY,UNIQUE KEY, KEY etc.) to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#g1053592]Oracle constraints.
(3) modify some datatype to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i45441]Oracle datatype
(4) think how to convert auto_increment ([url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6015.htm#i2067093]Sequence, [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7004.htm#i2235611]Beffore Trigger etc. on Oracle)
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref864
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm -
Hello,
can I upload and run on apex.oracle.com my own php or jsp scripts ?
Thank youNo.
-
Convertir PHP a PDF
Hola foreros.
Me preguntaba si alguien sabe alg�n c�digo,
programa MXP que me permita
convertir PHP a PDF con un bot�n.
Me explico. El cliente ve X pagina y desea que esa
informaci�n que esta
viendo pueda descargarlo en PDF.
Alguna ayudaNada, usas los valores extraidos de tu base de datos donde lo
necesites.
Si te fijas en el extracto de c�digo que te he dejado
en gran parte de �l
uso informaci�n sacada de la base de datos
($row_parte['t_doc'], por
ejemplo). Es cuesti�n de ir mezcl�ndolo donde
corresponda para que el
documento quede bien formateado.
Hay un par de librer�as derivadas de FPDF que admiten
directamente todo
c�digo html y css de la p�gina (no soporta
todas las etiquetas!!) pero
cuando tuve que hacer este trabajo vi m�s
c�modo hacelo as�, haciendo uso de
algo de html (<br> principalmente) e ir l�nea a
l�nea.
Saludos,
Julio Barroso
"Anuack Luna" <[email protected]> escribi� en el
mensaje
news:[email protected]...
| Ven y te hago una pregunta. El demo de c�digo es
para un desarrollo
| est�tico. Pero para que sea din�micos con
base de datos PHP que
necesitar�a.
|
| Gracias y espero tu colaboraci�n
|
| --
| Cualquier inquietud no dude en comunicarse con nosotros.
|
| Cordialmente
|
|
| ___________________________
| Daniel Fernando Luna S�nchez
| Anuack Technology de Colombia
| Celular : 316 - 3341135
| PBX (+57)(+7) 6819981- 6781918 Bucaramanga. Santander.
Colombia
| Servicio al Cliente de 8:00 AM a 10:00 PM (GMT -05:00)
| Registro de Dominios
| Hosting (Hospedaje Web) Compartido O Dedicado
| Administradores de Contenidos Web
| Aplicaciones Web
| Dise�o Web - Multimedia
| Voz Sobre IP ( VoIP )
|
| NO SPAM NOTIFICACI�N LEGAL Y CONFIDENCIAL
| La Informaci�n contenida en este e-mail es
confidencial y solo puede ser
| utilizada por el individuo o la compa��a a la
cual est� dirigido.
| Si no es usted el destinatario autorizado, cualquier
retenci�n, difusi�n,
| distribuci�n o copia de este mensaje est�
prohibida y es sancionada por la
| ley
| Si por error recibe este mensaje favor reenviar y borrar el
mensaje
recibido
| inmediatamente
|
| NO SPAM LEGAL AND CONFIDENTIAL NOTIFICATION
| The information on this e-mail is intended to be confid
| "Julio B." <[email protected]>
escribi� en el mensaje
| news:[email protected]...
| > Hay varias formas de hacerlo, pero todo
depender� del acceso que tengas
al
| > servidor.
| >
| > Si no tienes total acceso para instalar/desinstalar
programas solo te
| queda
| > la opci�n de crearte alguna plantilla y luego
rellenarla con los datos
| > extraido de tu p�gina de manera din�mica
para a continuaci�n
devolv�rsela
| al
| > cliente como pdf. Hay varias librer�as que te
permiten hacer algunas
cosas
| > con el pdf, pero son muy simples y TODO (l�nea
por l�nea) hay que
| > programarlo a mano.
| >
| > Si tienes total acceso a tu servidor (linux, por
supuesto) puedes
| instalarte
| > una "impresora virtual" donde enviar�as la
p�gina, recoger�as el pdf y
se
| lo
| > enviar�as al cliente.
| >
| > Por ejemplo, con la clase FPDF tuve que programar una
simple p�gina para
| que
| > la mostrara como PDF para un hotel, te dejo solo una
parte del c�digo
que
| te
| > genera el archivo para que veas que es un trabajo de
"chinos":
| >
| > $pdf=new PDF_HTML('P','mm','A5');
| > $pdf->Open();
| > $pdf->AddPage();
| > $pdf->SetDisplayMode(fullpage);
| > $pdf->SetAutoPageBreak(1,13);
| > $pdf->SetLeftMargin(25);
| > $pdf->SetFont('Arial');
| > $pdf->SetFontSize(10);
| > $pdf->WriteHTML('<b><p
align="center">Parte de entrada de viajeros</p><p
| >
align="center">Hoja-registro</p></b><br>');
| > $pdf->SetFontSize(8);
| > $pdf->WriteHTML('<p
align="center"><u>Datos del
establecimineto</u></p>');
| >
| > $pdf->WriteHTML('NIF:');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML(' B-xxxxxxxx<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Nombre del establecimiento:');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML(' HOTEL xxxxxxxxx<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Municipio:');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML(' xxxxxxxxx<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Provincia:');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML(' xxxxxxxxxx<br>');
| > $pdf->SetFont('');
| >
| > $pdf->SetFont('Arial','', 6);
| > $pdf->WriteHTML('<p align="center">Sello del
| >
establecimiento</p><BR><br><br><br>');
| >
| > $pdf->SetFont('Arial','B', 10);
| > $pdf->WriteHTML('<p><i><b>DATOS
DEL VIAJERO<b></i></p><BR><br>');
| >
| > $pdf->SetFont('Arial','', 8);
| >
| > $pdf->WriteHTML('N�mero de documento de
identidad: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['n_doc'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Tipo de documento: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['t_doc'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Fecha de expedici�n del
documento: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['f_doc'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Primer apellido: ');
| > $pdf->SetFont('Arial','B');
| >
$pdf->WriteHTML($row_parte['1_apellido'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Segundo apellido: ');
| > $pdf->SetFont('Arial','B');
| >
$pdf->WriteHTML($row_parte['2_apellido'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Nombre: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['nombre'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Sexo: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['sexo'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Fecha de nacimiento: ');
| > $pdf->SetFont('Arial','B');
| >
$pdf->WriteHTML($row_parte['f_nacimiento'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Pa�s de nacionalidad: ');
| > $pdf->SetFont('Arial','B');
| > $pdf->WriteHTML($row_parte['pais'].'<BR>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('Fecha de entrada: ');
| > $pdf->SetFont('Arial','B');
| >
$pdf->WriteHTML($row_parte['f_entrada'].'<BR><br>');
| > $pdf->SetFont('');
| >
| > $pdf->WriteHTML('<p
align="center">'.$row_parte['fecha'].'</p>');
| > $pdf->WriteHTML('<p align="center">
| > Firma del
viajero</p><br><br><br><br><br><br>');
| >
| >
| > $pdf->SetFont('Arial','', 6);
| > $pdf->Write(2,'La recogida y tratamiento se
har� de acuerdo con la Ley
| > Org�nica 15/1999, de 13 de diciembre, de
Protecci�n de Datos de Car�cter
| > Personal y al amparo de lo dispuesto en el
art�culo 12.1 de la Ley
| Org�nica
| > 1/1992, de 21 de febrero, sobre Protecci�n de
la Seguridad Ciudadana.');
| > $pdf->SetFont('Arial','', 8);
| > $pdf->text('110', '43', 'Parte n�');
| > $pdf->SetFont('Arial','B', 8);
| > $pdf->text('121', '43', $row_parte['n_parte']);
| > $pdf->Output();
| >
| >
| > Y eso que es una cosa sencilla...
| >
| > Saludos,
| >
| > Julio Barroso
| >
| >
|
| -
From PHP to JSP for a search-responder.php
I have been asked to use the "search-as-you-type" solution offered up by Google at [http://code.google.com/p/search-as-you-type/|http://code.google.com/p/search-as-you-type/]. The documentation offered by Google is pretty much straight forward but of course the actual piece of code that gets the data is built in PHP and my client needs this to be used on a page serving up JSP.
I am learning JSP and moving from PHP and ASP and learning quickly but not quick enough to finish the project.
Would anyone be able and willing to help me convert the functions in the following PHP code into JSP?
Thanks in advance to anyone who takes the time to help me.
<?php
* Copyright (C) 2006 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Search-as-you-type sample Ajax responder
// Adding a cache control so that browsers won't cache Ajax requests
header("Cache-Control: no-cache");
header("Content-Type: text/html; charset=UTF-8");
* Get the sample data from the text file.
* @return array Loaded data
function GetData() {
$data = array();
$file = file("test-data.txt");
foreach($file as $record) {
$record = explode("|", trim($record));
if (count($record) == 4) { // Ignore invalid lines
$data[] = $record;
return $data;
* Get the results based on user's query.
* @param string $query Query
* @param array $data Sample data
* @return array Result array
function GetResults($query, $data) {
$results = array();
$queryLength = strlen($query);
foreach ($data as $record) {
if (substr(strtolower($record[0]), 0, $queryLength) == $query) {
$result = array();
$result['name'] = $record[0];
$result['type'] = $record[1];
$result['content'] = $record[2];
$result['moreDetailsUrl'] = $record[3];
$result['style'] =
($query == strtolower($record[0])) ? 'expanded' : 'normal';
$results[] = $result;
return $results;
// Get the data and the query
$data = GetData();
$query = strtolower(ltrim($_GET['query']));
// Build response
$response = array();
$response['query'] = $query;
$response['results'] = GetResults($query, $data);
if (count($response['results']) == 1) {
$response['autocompletedQuery'] = $response['results'][0]['name'];
// Output response
echo "searchAsYouType.handleAjaxResponse(";
echo json_encode($response);
echo ");";
?>Thanks for your comment Gimbal2.
I have already been thoroughly surprised at how different JSP is from PHP. I am finding quite hard to wrap my head around the whole process to be honest.
I am beginning to see that JSP and PHP work in a totally different way than each other.
I am not technically trying to translate or convert the PHP file as much as I am trying to build a file in JSP that does the same functions. The main functions of the PHP script are commented by Google and should be easily enough re-written in JSP in order to produce similar results.
Since the output needs to be in a JSON format when passed to the .js file you'd think this would be better suited as a .jsp file as well or even a JAVA Applet, Servlet or even a bean. Since the whole site is already built in JSP for a multitude of other functions it seems likely that adding on more to read data from a source file and send it back to the .JS would be straight forward, but I could be wrong. But again I am not familiar enough with JAVA or JSP (yet) to make heads or tails of this.
1. // Adding a cache control so that browsers won't cache Ajax requests
2. * Get the sample data from the text file. @return array Loaded data
3. * Get the results based on user's query.
* @param string $query Query
* @param array $data Sample data
* @return array Result array
4. // Get the data and the query
5. // Build response
6. // Output response -
Hi,
i'am beginning of java programming...
I need help plz to convert this part of PHP code to JSP code :
$fp = fopen("../commun/param".$param.".txt", 'r');
while ($str=fgets($fp,4096)) eval( "".$str.";" );
fclose($fp);ThksThe best way to do so is take php syntax find a way to do it in jsp and recode it
-
Help me to convert Java and Jsp Files into WAR File!!!!
I need someone to help me to convert some java servlet files and jsp files into a WAR file. I need it URGENTLY and I'll be very grateful to anyone who is willing to help me! My email is [email protected] Thanks!!!!
Are the Oracle JDBC drivers 11g used?
oracle.jdbc.driver.OracleDriver is not supported in 11g drivers.
Please replace with:
oracle.jdbc.OracleDriver -
Hi all,
I have a problem. We have a portal (weblogic) and we want to integrate into portal
sites that developed in php. Is this possible?
Thank you
TamasJSP without java is a bit like PHP without html
...only worse.Which is why I'm looking for a book or onlinetutorial
which teaches Java with a focus on JSP.Well that's nice ...but YOU were the one who asked for
advice from people who you may assume to know more
than you do. Take it or leave it, makes bugger all
dif'rence to me ... erm, learn java first.I want to learn Java, but I don't have much use for it outside of JSP. Aren't there any books which teach Java, but in the context of web development? -
Converting Applet to JSP or JSF
Hello All,
I have a web application with Applet and Corba. It is rather old so I
want to migrate my Applets to a modern web application, with JSP or
JSF.
However number of applets is very huge. So I am looking a way to
convert my Applet to JSF/JSP etc. automatically.
Is there anyway to do that?
Thanks,
aduranHello cotton.m,
Thanks for the answer. You are right. But at least, is there any way to convert GUI (awt to JSP/JSF etc.) from applet to HTML look, without business logic or any other stuff. -
Are there any tools that automate the conversion of SSJS to JSP?"
What about a "wrapper" servlet to run the SSJS, do they exist? We are upgrading to Iplanet Web Server 6.0 and are looking for alternatives to a re-write.
Alternatively is their any way to "enhance" 6.0 to get ssjs support? (iplanet is dropping ssjs support)
[email protected]Hi,
"Converting SSJS Applications" section of "iPlanet Web Server, Enterprise Edition Programmer's Guide to Servlets"
contains information about converting Server-Side JavaScript applications to JSPs .
You can find more information on this at
http://docs.iplanet.com/docs/manuals/enterprise/50/servlets/xlwconv.htm
Hope this helps.
Best Regards
Gayam_Slash -
Convert PHP Site to AIR Application
I am working in an educational institute. I developed a website for controlling students admission & scheduling. This is only for departmental use. I like to convert this application to a standalone desktop application by using adobe air. In this PHP application form submission and data retrieving except some complex pages done through http request.
I am really confused, where I can start, what are the steps? is it need to convert all PHP to Ajax? is it need to change all graphics & graphic menus?
Please help…
thanksHave you installed an Apache Testing Server on your machine yet? If you're using Windows, you can install Wamp or Xampp server with phpMyAdmin to help you manage the MySql databases on your local machine.
Setting up a PHP environment in Dreamweaver
http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html
Once your testing server is installed, you'll need to define your testing server in DW. See screenshots below. I'm using wamp server. And my web site folder is in the default web directory -- wamp\www\
Advanced tab:
Final screen:
Nancy O. -
Convert PHP Email Code to Using SMTP Authentication
One of my contact forms no longer is able to send (it used to until some server updates were made), for it keeps posting the following error:
Warning: mail() [function.mail]: SMTP server response: 501 5.1.7 Invalid address in C:\contact.php on line 71
This form does work on three other servers, so obviously the form is in working order but not on this particular server.
I was recommended to "set the PHP script up to log in to the SMTP server" using this example:
http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
I've only gotten this far and cannot figure out how to actually create it to SEND:
<?php
// set flag to indicate whether mail has been sent
$mailSent = false;
if (array_key_exists('eList', $_POST)) {
// mail processing script
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
$_POST = array_map('stripslashes_deep', $_POST);
$email = $_POST['email'];
// check for valid email address
$pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
$error['email'] = 'Please enter a valid email address';
// validate the input, beginning with name
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your First Name';
$lname = trim($_POST['lname']);
if (empty($lname)) {
$error['lname'] = 'Please enter your Last Name';
$department = $_POST['department'];
if ($_POST['department'] == '') {
$error['department'] = 'Please select a Department';
// check the content of the text area
$messageBody = trim($_POST['message']);
if (empty($messageBody)) {
$error['message'] = 'Please enter your message';
// initialize variables
if (!empty($_POST['url'])) {
$to = '[email protected]';//
$subject = 'Suspected as SPAM';
$host = 'smptout.serverserver.net';
$username = 'username';
$password = 'password';
} else {
$to = '[email protected]';//
$subject = 'Here we are';
$host = 'smptout.serverserver.net';
$username = 'username';
$password = 'password';
$SpamErrorMessage = "No URLs permitted";
if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$lname")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$messageBody")) {echo "$SpamErrorMessage"; exit();} // check for spam
//build the message
$smtp = Mail::factory('smtp',
array('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$message = "To: $department\r\n\r\n";
$message .= "From: $name $lname\r\n";
$message .= "$email\r\n\r\n";
$message .= "Question/Comment: $messageBody";
//build the additional headers
$additionalHeaders = "From: Contact <[email protected]>\r\n";
$additionalHeaders .= "Reply-To: $email";
//send the email if there are not errors
if (!isset($error)) {
$mailSent = mail($to, $subject, $message, $additionalHeaders);
// check that the mail was sent successfully
if (!$mailSent) {
$error['notSent'] = 'Sorry, there was a problem sending your mail. Please try later.';
?>
Thank you for your help!Anyone?
-
I'm new to jsp and was just wondering how I go about adding my classpath to the jsp page... for example, I have a class like:public class testDriver{
public static void main(String args[]){
MyOtherClass other = new MyOtherClass();
System.out.println(other.ReturnAString());
}Ok. Now MyOtherClass does all sorts of hoobadeedoo, and I need to run my testDriver class with:"java -classpath .\;%AXISPATH%;%XERCESPATH%;%UDDI4JPATH% testDriver"As you can see, I have lots of classes - the AXISPATH, for example, points to 8 .jar files in the axis directory.
My question is, How can I turn the testDriver class into a jsp page? Do I have to copy ALL of the .jar files to my \WEB-INF\lib directory? Am I missing the point here?!
As you can see, Im pretty new to this so any help would be appreciated!
Thanks,
nmoogWell, copying all the .JAR files works! Im happy!
But is this the best way? do I need to copy them for every project that I use them in? -
Hola.
Quisiera saber si alguno sabe como hacer una insercion en una
pagina php a
dos tablas diferentes en un mismo formulario (en Dreamweaver
MX), ya tengo
la pagina php pero solo me inserta a una table necesito que
los datos de
algunos campos lo haga en otra tabla pero que el usuario solo
de una sola
vez en el boton registrar, muchas gracias por la ayuda que me
puedan
brindar.
cordial saludo
HaroldHola.
Quisiera saber si alguno sabe como hacer una insercion en una
pagina php a
dos tablas diferentes en un mismo formulario (en Dreamweaver
MX), ya tengo
la pagina php pero solo me inserta a una table necesito que
los datos de
algunos campos lo haga en otra tabla pero que el usuario solo
de una sola
vez en el boton registrar, muchas gracias por la ayuda que me
puedan
brindar.
cordial saludo
Harold
Maybe you are looking for
-
In previous versions of OS X, there were ways to enable 2 (or more) weeks view in iCal / Calendar. There was a debug menu and then there was a Terminal script that allowed this. Yosemite has seem to take this option away. Has anyone found a way to en
-
When I go to do an update for my apps on my iPhone 4S it says that I am connected to the Chinese iTunes Store and tha I need to switch to the US store. How do you do that?
-
Export data from a scanned form.
Hello I have several forms that users will fill out and email back. The data can then be extracted using Adobe's forms tools. However, at times the form is returned either on paper or scanned. Is there a way to extract the data from the scanned for
-
I just switched to CS5 on Snow Leopard and am doing layouts in InDesign. I need to create PDFs for our Press using the Manufacturer's PPD. Is there a way to create a PDF being able to select specific PPDs. ANy help would be greatly appreciated. Thank
-
New In Java.....
Hi, I'm a Lotus based programmer and just started to learn Java few month ago. After the few month self-study, I found that there are too many classes and interface to remembers. I'm having a hard time to remembers all the classes. I have few questio