Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中html表单的替代方案是什么?_Php_Html_Codeigniter - Fatal编程技术网

php中html表单的替代方案是什么?

php中html表单的替代方案是什么?,php,html,codeigniter,Php,Html,Codeigniter,当用户使用某种形式发布某些数据时,我正在发送电子邮件。这是发送电子邮件的条件 <?php if($_SERVER["REQUEST_METHOD"] == "POST") { $message='Thanks for registerring yourself'; require "public/api/phpmailer/class.phpmailer.php"; //include phpmailer class // Instantiate Class

当用户使用某种形式发布某些数据时,我正在发送电子邮件。这是发送电子邮件的条件

    <?php
if($_SERVER["REQUEST_METHOD"] == "POST")
{

$message='Thanks for registerring yourself';
    require "public/api/phpmailer/class.phpmailer.php"; //include phpmailer class

    // Instantiate Class  
    $mail = new PHPMailer();  

    // Set up SMTP  
    $mail->IsSMTP();                // Sets up a SMTP connection  
    $mail->SMTPAuth = true;         // Connection with the SMTP does require authorization    
    $mail->SMTPSecure = "ssl";      // Connect using a TLS connection  
    $mail->Host = "smtp.gmail.com";  //Gmail SMTP server address
    $mail->Port = 587;  //Gmail SMTP port
    $mail->SMTPSecure = "tls"; 
    $mail->SMTPDebug = 1;

    $mail->Encoding = '7bit';

    // Authentication  
    $mail->Username   = '*********'; // Your full Gmail address
    $mail->Password   = '*********'; // Your Gmail password

    // Compose
    $email = $_POST['InputEmail'];
    $mail->MsgHTML($message);

    // Send To  
    $mail->AddAddress($email, "RahulName"); // Where to send it - Recipient
    $result = $mail->Send();        // Send!  
    $message = $result ? 'Successfully Sent!' : 'Sending Failed!';      
    unset($mail);

}
?>

表单声明是这样的。当我使用它时,我可以发送电子邮件,但表单数据不会进入数据库

  <form method="post" id="login_form" action="" >

但当我使用它时,我可以在数据库中发送数据,但不能发送电子邮件

<?php echo form_open_multipart('upload/do_upload');?> 


做这两件事的解决方案是什么?

我假设您使用的是CodeIgniter

对于您的问题,等效的HTML代码是

您应该参考CI的用户指南

还可以查看帮助文件的源代码:


希望这有帮助。

这不是mysql的问题。html中的替代方法是什么?我也上传了邮件代码。html中此功能的唯一替代方法是
标记。但它不是一个替代方案,因为
form\u open\u multipart
生成此标记。所以,它们是一样的。要解决您的问题,您必须在发送电子邮件之前或之后在
if
块中手动将数据保存到DB。正如@Dwand所说,您应该编写PHP代码以获取表单数据并保存到数据库中。我想是你干的。但我没有在您的代码中看到任何DB交互的代码片段。如果您仍然无法解决问题,请增强您的问题或发布整个代码,以便我们提供帮助