Jump to content

Call A FUction


AnotherQuestion

Recommended Posts

Im a newbie with PHP and am trying to write a script within Dreamweaver that quiries Mysql for 2 values. If they exist I want to send an email containing a random Password & the username.

 

The User enters three values on a form. These are EMail Address, PostCode & AccNo. Then hits submit. The action then points to an new file checkexisting.php

 

Dont think Im doing things the write way. I have written & tested the email script. It works with the exception of sending the username & password.

 

the script goes somthing like this:

 

<?php require_once('../../../Connections/AutoPart.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

 

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

 

$colname_RsCustomer = "-1";

if (isset($_SESSION['AccountNo'])) {

  $colname_RsCustomer = $_SESSION['AccountNo'];

}

$colname1_RsCustomer = "-1";

if (isset($_SESSION['PCode'])) {

  $colname1_RsCustomer = $_SESSION['PCode'];

}

mysql_select_db($database_AutoPart, $AutoPart);

$query_RsCustomer = sprintf("SELECT * FROM Customer WHERE KeyCode = %s AND PCode = %s", GetSQLValueString($colname_RsCustomer, "text"),GetSQLValueString($colname1_RsCustomer, "text"));

$RsCustomer = mysql_query($query_RsCustomer, $AutoPart) or die(mysql_error());

$row_RsCustomer = mysql_fetch_assoc($RsCustomer);

$totalRows_RsCustomer = mysql_num_rows($RsCustomer);

If ($totalRows_RsCustomer <=1) then Goto Function Send_MailConfirm ;

 

 

 

 

?>

<?Php

Function Check_Account ($CheckAccount){}

 

if (!function_exists("Send_MailConfirm")) {

function Send_MailConfirm

$to  = $_SESSION['EMail'];

$subject = 'Online account Set-up';

$PasswordStr = $_SESSION['Password'];

$EmailStr = $_SESSION['EMail'];

// the messgae body

$message = '

<html>

<head>

  <title>Online account Set-up</title>

</head>

<body>

  <p>Here are the details for you online login</p>

  <p> Your username is: $EmailStr </p> "\r\n" ;

<P>Your password is: $PasswordStr </p> "\r\n" ;

</body>

</html>

';

 

// When sending HTML mail, the Content-type header must be set

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: Account Setup <[email protected]>' . "\r\n";

 

 

// The next line sends the mail

mail($to, $subject, $message, $headers);}

 

?>

 

I keep getting an error

Parse error: syntax error, unexpected T_STRING in /home/default/peakperformancewales.co.uk/user/htdocs/NewSite/SelfService/Scripts/CheckExisting.php on line 47

 

Link to comment
https://forums.phpfreaks.com/topic/171545-call-a-fuction/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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